Browse code

- bad network addresses are now automatically fixed (e.g. 192.168.1.80/27 => 192.168.1.64/27) - tm has a new parameter: restart_fr_on_each_reply. If set (default) fr_inv timer will be restarted for each provisional reply, if not set it will be restarted only for the first reply and for replies >=180 (but only if increasing, eg.: 180, 181 ...). Usefull when dealing with bad UAs that re-transmit 180s.

Andrei Pelinescu-Onciul authored on 01/10/2004 17:19:19
Showing 5 changed files
... ...
@@ -50,7 +50,7 @@ MAIN_NAME=ser
50 50
 VERSION = 0
51 51
 PATCHLEVEL = 8
52 52
 SUBLEVEL =   99
53
-EXTRAVERSION = -dev7
53
+EXTRAVERSION = -dev8
54 54
 
55 55
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
56 56
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
... ...
@@ -31,6 +31,7 @@
31 31
  * History:
32 32
  * --------
33 33
  *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free
34
+ *  2004-10-01  mk_net fixes bad network addresses now (andrei)
34 35
  */
35 36
 
36 37
 
... ...
@@ -45,7 +46,10 @@
45 45
 struct net* mk_net(struct ip_addr* ip, struct ip_addr* mask)
46 46
 {
47 47
 	struct net* n;
48
+	int warning;
49
+	int r;
48 50
 	
51
+	warning=0;
49 52
 	if ((ip->af != mask->af) || (ip->len != mask->len)){
50 53
 		LOG(L_CRIT, "ERROR: mk_net: trying to use a different mask family"
51 54
 				" (eg. ipv4/ipv6mask or ipv6/ipv4mask)\n");
... ...
@@ -58,6 +62,18 @@ struct net* mk_net(struct ip_addr* ip, struct ip_addr* mask)
58 58
 	}
59 59
 	n->ip=*ip;
60 60
 	n->mask=*mask;
61
+	for (r=0; r<n->ip.len/4; r++) { /*ipv4 & ipv6 addresses are multiple of 4*/
62
+		n->ip.u.addr32[r] &= n->mask.u.addr32[r];
63
+		if (n->ip.u.addr32[r]!=ip->u.addr32[r]) warning=1;
64
+	};
65
+	if (warning){
66
+		LOG(L_WARN, "WARNING: mk_net: invalid network address/netmask "
67
+					"combination fixed...\n");
68
+		print_ip("original network address:", ip, "/");
69
+		print_ip("", mask, "\n");
70
+		print_ip("fixed    network address:", &(n->ip), "/");
71
+		print_ip("", &(n->mask), "\n");
72
+	};
61 73
 	return n;
62 74
 error:
63 75
 	return 0;
... ...
@@ -67,26 +83,20 @@ error:
67 67
 
68 68
 struct net* mk_net_bitlen(struct ip_addr* ip, unsigned int bitlen)
69 69
 {
70
-	struct net* n;
70
+	struct ip_addr mask;
71 71
 	int r;
72 72
 	
73 73
 	if (bitlen>ip->len*8){
74 74
 		LOG(L_CRIT, "ERROR: mk_net_bitlen: bad bitlen number %d\n", bitlen);
75 75
 		goto error;
76 76
 	}
77
-	n=(struct net*)pkg_malloc(sizeof(struct net));
78
-	if (n==0){
79
-		LOG(L_CRIT, "ERROR: mk_net_bitlen: memory allocation failure\n"); 
80
-		goto error;
81
-	}
82
-	memset(n,0, sizeof(struct net));
83
-	n->ip=*ip;
84
-	for (r=0;r<bitlen/8;r++) n->mask.u.addr[r]=0xff;
85
-	if (bitlen%8) n->mask.u.addr[r]=  ~((1<<(8-(bitlen%8)))-1);
86
-	n->mask.af=ip->af;
87
-	n->mask.len=ip->len;
77
+	memset(&mask,0, sizeof(mask));
78
+	for (r=0;r<bitlen/8;r++) mask.u.addr[r]=0xff;
79
+	if (bitlen%8) mask.u.addr[r]=  ~((1<<(8-(bitlen%8)))-1);
80
+	mask.af=ip->af;
81
+	mask.len=ip->len;
88 82
 	
89
-	return n;
83
+	return mk_net(ip, &mask);
90 84
 error:
91 85
 	return 0;
92 86
 }
... ...
@@ -61,6 +61,7 @@
61 61
  *  2004-02-13: t->is_invite and t->local replaced with flags (bogdan)
62 62
  *  2004-02-18  fifo_t_reply imported from vm module (bogdan)
63 63
  *  2004-08-23  avp list is available from failure/on_reply routes (bogdan)
64
+ *  2004-10-01  added a new param.: restart_fr_on_each_reply (andrei)
64 65
  */
65 66
 
66 67
 
... ...
@@ -95,6 +96,10 @@
95 95
 #include "fix_lumps.h"
96 96
 #include "t_stats.h"
97 97
 
98
+
99
+/* restart fr timer on each provisional reply, default yes */
100
+int restart_fr_on_each_reply=1;
101
+
98 102
 /* are we processing original or shmemed request ? */
99 103
 enum route_mode rmode=MODE_REQUEST;
100 104
 
... ...
@@ -1186,6 +1191,7 @@ int reply_received( struct sip_msg  *p_msg )
1186 1186
 {
1187 1187
 
1188 1188
 	int msg_status;
1189
+	int last_uac_status;
1189 1190
 	char *ack;
1190 1191
 	unsigned int ack_len;
1191 1192
 	int branch;
... ...
@@ -1212,6 +1218,7 @@ int reply_received( struct sip_msg  *p_msg )
1212 1212
 		"uac[%d]=%d local=%d is_invite=%d)\n",
1213 1213
 		t->uas.status, branch, uac->last_received, 
1214 1214
 		is_local(t), is_invite(t));
1215
+	last_uac_status=uac->last_received;
1215 1216
 
1216 1217
 	/* it's a cancel ... ? */
1217 1218
 	if (get_cseq(p_msg)->method.len==CANCEL_LEN 
... ...
@@ -1291,7 +1298,10 @@ int reply_received( struct sip_msg  *p_msg )
1291 1291
 	} 
1292 1292
 
1293 1293
 	/* update FR/RETR timers on provisional replies */
1294
-	if (msg_status<200) { /* provisional now */
1294
+	if (msg_status<200 && ( restart_fr_on_each_reply ||
1295
+				( (last_uac_status<msg_status) &&
1296
+					((msg_status>=180) || (last_uac_status==0)) )
1297
+			) ) { /* provisional now */
1295 1298
 		if (is_invite(t)) {
1296 1299
 			/* invite: change FR to longer FR_INV, do not
1297 1300
 			   attempt to restart retransmission any more
... ...
@@ -35,6 +35,9 @@
35 35
 
36 36
 #include "h_table.h"
37 37
 
38
+
39
+extern int restart_fr_on_each_reply;
40
+
38 41
 /* reply processing status */
39 42
 enum rps {
40 43
 	/* something bad happened */
... ...
@@ -71,6 +71,7 @@
71 71
  *              takes no parameters -> forwards to uri (bogdan)
72 72
  *  2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
73 73
  *  2004-02-18  t_reply exported via FIFO - imported from VM (bogdan)
74
+ *  2004-10-01  added a new param.: restart_fr_on_each_reply (andrei)
74 75
  */
75 76
 
76 77
 
... ...
@@ -265,6 +266,7 @@ static param_export_t params[]={
265 265
 	{"noisy_ctimer",          INT_PARAM, &noisy_ctimer                          },
266 266
 	{"uac_from",              STR_PARAM, &uac_from                              },
267 267
 	{"unix_tx_timeout",       INT_PARAM, &tm_unix_tx_timeout                    },
268
+	{"restart_fr_on_each_reply", INT_PARAM, &restart_fr_on_each_reply        },
268 269
 	{0,0,0}
269 270
 };
270 271