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 112
 	}
113 113
 	DBG("After parse_msg...\n");
114 114
 
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 115
 
125
-	/* ... and clear branches from previous message */
116
+	/* ... clear branches from previous message */
126 117
 	clear_branches();
127 118
 
128 119
 	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 150
 		}
151 151
 #endif
152 152
 
153
-		/* exec routing script */
154 153
 		DBG("preparing to run routing scripts...\n");
155 154
 #ifdef  STATS
156 155
 		gettimeofday( & tvb, &tz );
157 156
 #endif
157
+		/* execute pre-script callbacks, if any; -jiri */
158
+		/* if some of the callbacks said not to continue with
159
+		   script processing, don't do so
160
+		   if we are here basic sanity checks are already done
161
+		   (like presence of at least one via), so you can count
162
+		   on via1 being parsed in a pre-script callback --andrei
163
+		*/
164
+		ret=exec_pre_cb(msg);
165
+		if (ret<=0){
166
+			if (ret<0) goto error;
167
+			else goto end; /* drop the message -- no error -- andrei */
168
+		}
169
+		/* exec the routing script */
158 170
 		if (run_actions(rlist[0], msg)<0) {
159 171
 			LOG(L_WARN, "WARNING: receive_msg: "
160 172
 					"error while trying script\n");
... ...
@@ -194,6 +199,19 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
194 194
 		STATS_RX_RESPONSE ( msg->first_line.u.reply.statuscode / 100 );
195 195
 #endif
196 196
 		
197
+		/* execute pre-script callbacks, if any; -jiri */
198
+		/* if some of the callbacks said not to continue with
199
+		   script processing, don't do so
200
+		   if we are here basic sanity checks are already done
201
+		   (like presence of at least one via), so you can count
202
+		   on via1 being parsed in a pre-script callback --andrei
203
+		*/
204
+		ret=exec_pre_cb(msg);
205
+		if (ret<=0){
206
+			if (ret<0) goto error;
207
+			else goto end; /* drop the message -- no error -- andrei */
208
+		}
209
+
197 210
 		/* send the msg */
198 211
 		forward_reply(msg);
199 212
 
... ...
@@ -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)