Browse code

more debug info in data_lump, iptel. cfg extended

Jiri Kuthan authored on 10/06/2002 19:12:16
Showing 3 changed files
... ...
@@ -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 115
 		break;
116 116
 	};
117 117
 
118
+	# -------------------- testing accounts ----------------
119
+#XX
120
+	if (uri=~"sip:333.*@iptel\.org") {
121
+		forward( 195.113.147.6, 5060 );
122
+		break;
123
+	} ;
124
+
125
+	if (uri=~"sip:everloop@iptel\.org") {
126
+		t_relay();
127
+		break;
128
+	}	;
129
+
130
+	if (uri=~"sip:looptester@iptel\.org") {
131
+		seturi("sip:lt0@iptel.org");
132
+		t_relay();
133
+		break;
134
+	} else if (uri=~"sip:lt0@iptel\.org") {
135
+		seturi("sip:lt1@iptel.org");
136
+		t_relay();
137
+		break;
138
+	} else if (uri=~"sip:lt1@iptel\.org") {
139
+		seturi("sip:lt2@iptel.org");
140
+		t_relay();
141
+		break;
142
+	} else if (uri=~"sip:lt2@iptel\.org") {
143
+		seturi("sip:lt3@iptel.org");
144
+		t_relay();
145
+		break;
146
+	} else if (uri=~"sip:lt3@iptel\.org") {
147
+		seturi("sip:lt4@iptel.org");
148
+		t_relay();
149
+		break;
150
+	} else if (uri=~"sip:lt4@iptel\.org") {
151
+		seturi("sip:lt5@iptel.org");
152
+		t_relay();
153
+		break;
154
+	} else if (uri=~"sip:lt5@iptel\.org") {
155
+		seturi("sip:lt6@iptel.org");
156
+		t_relay();
157
+		break;
158
+	} else if (uri=~"sip:lt6@iptel\.org") {
159
+		seturi("sip:lt7@iptel.org");
160
+		t_relay();
161
+		break;
162
+	} else if (uri=~"sip:lt7@iptel\.org") {
163
+		seturi("sip:lt8@iptel.org");
164
+		t_relay();
165
+		break;
166
+	} ; if (uri=~"sip:lt8@iptel\.org") {
167
+#	}   else if (uri=~"sip:lt8@iptel\.org") {
168
+		seturi("sip:lt9@iptel.org");
169
+		t_relay();
170
+		break;
171
+	} else if (uri=~"sip:lt9@iptel\.org") {
172
+		seturi("sip:lt0@iptel.org");
173
+		t_relay();
174
+		break;
175
+	} else if (uri=~"sip:lt0@iptel\.org") {
176
+		seturi("sip:lta@iptel.org");
177
+		t_relay();
178
+		break;
179
+	} else if (uri=~"sip:lta@iptel\.org") {
180
+		seturi("sip:ltb@iptel.org");
181
+		t_relay();
182
+		break;
183
+	};
184
+	# -------------------- Eo testing account ----------------
185
+
118 186
 	# Do strict routing if route headers present
119 187
 	rewriteFromRoute();
120 188
 
... ...
@@ -124,6 +197,8 @@ route{
124 124
 		sethost("iptel.org");
125 125
 #		t_relay_to("fox.iptel.org", "5066");
126 126
 		t_relay_to("fox.iptel.org", "6060");
127
+#XX
128
+# { sl_reply_error(); break; }
127 129
 		break;
128 130
 	};
129 131
 
... ...
@@ -135,7 +210,9 @@ route{
135 135
 
136 136
 	# sign of our domain: there is @ (username), :
137 137
     # (nothing) or . (host) in front of our domain name	
138
-	if (!(uri=~"[@:\.]iptel\.org([;:].*)*" 
138
+#XX
139
+#	if (!(uri=~"[@:\.]iptel\.org([;:].*)*" 
140
+	if (!(uri=~"[@:]iptel\.org([;:].*)*" 
139 141
 		| uri=~"[@:\.]195\.37\.77\.101([;:].*)*" |
140 142
 		uri=~"@195\.37\.77\.110([;:].*)*" )) {
141 143
 		route(2);
... ...
@@ -145,17 +222,26 @@ route{
145 145
 	# here we continue with requests for our domain...
146 146
 
147 147
 	# various aliases (might use a database in future)
148
+#	lookup_contact("aliases");
148 149
 	if (uri=~"sip:9040@") {
149
-		seturi("jiri@iptel.org");
150
+		seturi("sip:jiri@iptel.org");
151
+	};
152
+	if (uri=~"sip:9042@") {
153
+		seturi("sip:sisalem@iptel.org");
150 154
 	};
151 155
 	if (uri=~"sip:17@") {
152 156
 		seturi("sip:henry@siptest.wcom.com");
153 157
 	};
154
-	if (uri=~"sip:jirim@") {
158
+	if (uri=~"sip:jirim@"  ) {
155 159
 		seturi("sip:001795061546@iptel.org");
156 160
 	};
161
+	if ( uri=~"sip:info@" ) {
162
+		seturi("sip:jiri@mail.iptel.org");
163
+	};
157 164
 	# check again, if it is still for our domain after aliases
158
-	if ( !(uri=~"[@:\.]iptel\.org([;:].*)*" | 
165
+#XX
166
+#	if ( !(uri=~"[@:\.]iptel\.org([;:].*)*" | 
167
+	if ( !(uri=~"[@:]iptel\.org([;:].*)*" | 
159 168
 		uri=~"[@:\.]195\.37\.77\.101([;:].*)*" |
160 169
 		uri=~"@195\.37\.77\.110([;:].*)*" )) {
161 170
 		route(2);
... ...
@@ -168,23 +254,26 @@ route{
168 168
 	# avoid stealing incoming calls	
169 169
 	if (method=="REGISTER") {
170 170
 		log("LOG Request is REGISTER\n");
171
+		# prohibit attempts to grab someone else's To address 
172
+		# using  valid credentials; the only exception is the user
173
+		# 'replciator' permitted to generate 3-rd party registrations
174
+
175
+
171 176
 		if (!www_authorize(	"iptel.org" /* realm */, 
172
-#		if (!proxy_authorize(	"iptel.org" /* realm */, 
173 177
 			 				"subscriber" /* table name */ )) {
174 178
 			log("LOG: REGISTER has no credentials, sending challenge\n");
175 179
  			www_challenge(	"iptel.org" /* realm */, 
176
-#			proxy_challenge(	"iptel.org" /* realm */, 
177 180
 							"0" /* no qop -- M$ can't deal with it */);
178 181
 			break;
179 182
 		};
180
-		# prohibit attempts to grab someone else's To address 
181
-		# using  valid credentials
182
-		if (!check_to()) {
183
+
184
+		if (!is_user("replicator") & !check_to()) {
183 185
 			log("LOG: To Cheating attempt\n");
184 186
 			sl_send_reply("403", "That is ugly -- use To=id next time");
185 187
 			break;
186 188
 		};
187 189
 			
190
+
188 191
 		# update Contact database
189 192
        	log("LOG: REGISTER is authorized, saving location\n");
190 193
 		save_contact("location");
... ...
@@ -201,7 +290,7 @@ route{
201 201
 
202 202
 	# ---------- CPL demo - begin --------------
203 203
 	/* added by Bogdan for cpl demo - Dorgham request*/
204
-	if (uri=~"sip:test@.*" && method=="INVITE")
204
+	if (uri=~"sip:test@.*" & method=="INVITE")
205 205
 	{
206 206
 		log("SER : runing CPL!! :)\n");
207 207
 		if ( !cpl_run_script() )
... ...
@@ -222,23 +311,25 @@ route{
222 222
 	};
223 223
 	# -------------- CPL demo - end -------------
224 224
 	# ---------- forking demo2 - begin --------------
225
-	if (uri=~"sip:cebit@.*" && method=="INVITE") {
225
+	if (uri=~"sip:cebit@.*" & method=="INVITE") {
226 226
 		# Cisco phone on Jiri's desktop; Caution: DHCP address,
227 227
 		#  subject to change
228
-		seturi("sip:qwe@195.37.78.129");
228
+		seturi("sip:cebit@195.37.78.242");
229 229
 		# Jiri's desktop PC; Caution: DHCP address,
230 230
 		#  subject to change
231
-		t_fork_to_uri("sip:cebit@195.37.78.126");
231
+		# t_fork_to_uri("sip:cebit@195.37.78.126");
232 232
 		# gateway address; Caution: is PSTN number changes, it must
233 233
 		#   on the list of free destination bellow; otherwise the
234 234
 		#   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");
235
+		t_fork_to_uri("sip:001795061546@195.37.77.110");
236
+		#t_fork_to_uri( "sip:0016097265544@195.37.77.110");
237 237
 
238 238
 
239 239
 		t_fork_on_no_response("sip:cebit@mail.iptel.org");
240 240
 	
241 241
 		t_relay();
242
+#XX
243
+#{ sl_reply_error(); break; }
242 244
 		break;
243 245
 	};
244 246
 	# ---------- forking demo2 - end  --------------
... ...
@@ -263,12 +354,14 @@ route{
263 263
 	};
264 264
 
265 265
 	# requests from gateway should be RR-ed too
266
-	if (src_ip==195.37.77.110 && method=="INVITE")  {
266
+	if (src_ip==195.37.77.110 & method=="INVITE")  {
267 267
 		addRecordRoute();
268 268
 	};
269 269
 
270 270
 	# we now know we may, we know where, let it go out now!
271 271
 	t_relay();
272
+#XX
273
+#{ sl_reply_error(); break; }
272 274
 }
273 275
 
274 276
 # routing logic for outbound requests targeted out of our domain
... ...
@@ -301,13 +394,16 @@ route[2] {
301 301
 		};
302 302
 
303 303
 		t_relay();
304
+#XX
305
+#{ sl_reply_error(); break; }
304 306
 }
305 307
 
306 308
 # logic for calls through our PSTN gateway
307 309
 route[3] {
308 310
 	# free call destinations ... no authentication needed
309 311
 	if (uri=~"sip:001795061546@.*" | uri=~"sip:0016097265544.*" 
310
-		| uri=~"sip:[79][0-9][0-9][0-9]@.*") {
312
+		| uri=~"sip:[79][0-9][0-9][0-9]@.*" 
313
+		| uri=~"sip:98[0-9][0-9][0-9][0-9]") {
311 314
 		log("LOG: Free PSTN\n");
312 315
 		# let's log free calls for now too ...
313 316
 		setflag(1);
... ...
@@ -387,4 +483,33 @@ route[3] {
387 387
 
388 388
 
389 389
 	t_relay();
390
+#XX
391
+#{ sl_reply_error(); break; }
390 392
 }
393
+
394
+/*
395
+
396
+if (! t_newtran()) { 
397
+	# # retransmit whatever we have 
398
+	t_retransmit_reply(); 
399
+} else {
400
+	# do what you want to do 
401
+	if (send_sms()) { 
402
+		# things went well, send ok upstream
403
+		if (!t_send_reply("200", "yes sir, SMS sent over")) {
404
+			# if replying failed, retry statelessly 
405
+			sl_reply_error(); 
406
+		};
407
+	} else {
408
+		if (!t_send_reply("500", "SMS error :-(")) {
409
+			# if replying failed, retry statelessly 
410
+			sl_reply_error(); 
411
+		};
412
+	};
413
+	# transaction concluded -- junk it now
414
+	t_release(); 
415
+}
416
+t_unref();
417
+
418
+*/
419
+
... ...
@@ -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*/