Browse code

- exec_pre_cb called after basic sanity checks (at least 1 via present)

Andrei Pelinescu-Onciul authored on 30/04/2004 11:57:27
Showing 2 changed files
... ...
@@ -34,6 +34,8 @@
34 34
  *            tcp_read_req)
35 35
  * 2003-08-13 fixed exec_pre_cb returning 0 (backported from stable) (andrei)
36 36
  * 2004-02-06 added user preferences support - destroy_avps() (bogdan)
37
+ * 2004-04-30 exec_pre_cb is called after basic sanity checks (at least one
38
+ *            via present & parsed ok)  (andrei)
37 39
  */
38 40
 
39 41
 
... ...
@@ -112,17 +114,8 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
112 114
 	}
113 115
 	DBG("After parse_msg...\n");
114 116
 
115
-	/* execute pre-script callbacks, if any; -jiri */
116
-	/* if some of the callbacks said not to continue with
117
-	   script processing, don't do so
118
-	*/
119
-	ret=exec_pre_cb(msg);
120
-	if (ret<=0){
121
-		if (ret<0) goto error;
122
-		else goto end; /* drop the message -- no error -- andrei */
123
-	}
124 117
 
125
-	/* ... and clear branches from previous message */
118
+	/* ... clear branches from previous message */
126 119
 	clear_branches();
127 120
 
128 121
 	if (msg->first_line.type==SIP_REQUEST){
... ...
@@ -150,11 +143,23 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
150 143
 		}
151 144
 #endif
152 145
 
153
-		/* exec routing script */
154 146
 		DBG("preparing to run routing scripts...\n");
155 147
 #ifdef  STATS
156 148
 		gettimeofday( & tvb, &tz );
157 149
 #endif
150
+		/* execute pre-script callbacks, if any; -jiri */
151
+		/* if some of the callbacks said not to continue with
152
+		   script processing, don't do so
153
+		   if we are here basic sanity checks are already done
154
+		   (like presence of at least one via), so you can count
155
+		   on via1 being parsed in a pre-script callback --andrei
156
+		*/
157
+		ret=exec_pre_cb(msg);
158
+		if (ret<=0){
159
+			if (ret<0) goto error;
160
+			else goto end; /* drop the message -- no error -- andrei */
161
+		}
162
+		/* exec the routing script */
158 163
 		if (run_actions(rlist[0], msg)<0) {
159 164
 			LOG(L_WARN, "WARNING: receive_msg: "
160 165
 					"error while trying script\n");
... ...
@@ -194,6 +199,19 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
194 199
 		STATS_RX_RESPONSE ( msg->first_line.u.reply.statuscode / 100 );
195 200
 #endif
196 201
 		
202
+		/* execute pre-script callbacks, if any; -jiri */
203
+		/* if some of the callbacks said not to continue with
204
+		   script processing, don't do so
205
+		   if we are here basic sanity checks are already done
206
+		   (like presence of at least one via), so you can count
207
+		   on via1 being parsed in a pre-script callback --andrei
208
+		*/
209
+		ret=exec_pre_cb(msg);
210
+		if (ret<=0){
211
+			if (ret<0) goto error;
212
+			else goto end; /* drop the message -- no error -- andrei */
213
+		}
214
+
197 215
 		/* send the msg */
198 216
 		forward_reply(msg);
199 217
 
... ...
@@ -61,6 +61,7 @@ static inline void calc_crc_suffix( struct sip_msg *msg, char *tag_suffix)
61 61
 	str suffix_source[3];
62 62
 
63 63
 	ss_nr=2;
64
+	if (msg->via1==0) return; /* no via, bad message */
64 65
 	suffix_source[0]=msg->via1->host;
65 66
 	suffix_source[1]=msg->via1->port_str;
66 67
 	if (msg->via1->branch)