Bladeren bron

- 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 21 jaren geleden
bovenliggende
commit
092bc8184c
5 gewijzigde bestanden met toevoegingen van 40 en 15 verwijderingen
  1. 1 1
      Makefile.defs
  2. 23 13
      ip_addr.c
  3. 11 1
      modules/tm/t_reply.c
  4. 3 0
      modules/tm/t_reply.h
  5. 2 0
      modules/tm/tm.c

+ 1 - 1
Makefile.defs

@@ -50,7 +50,7 @@ MAIN_NAME=ser
 VERSION = 0
 PATCHLEVEL = 8
 SUBLEVEL =   99
-EXTRAVERSION = -dev7
+EXTRAVERSION = -dev8
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")

+ 23 - 13
ip_addr.c

@@ -31,6 +31,7 @@
  * History:
  * --------
  *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free
+ *  2004-10-01  mk_net fixes bad network addresses now (andrei)
  */
 
 
@@ -45,7 +46,10 @@
 struct net* mk_net(struct ip_addr* ip, struct ip_addr* mask)
 {
 	struct net* n;
+	int warning;
+	int r;
 	
+	warning=0;
 	if ((ip->af != mask->af) || (ip->len != mask->len)){
 		LOG(L_CRIT, "ERROR: mk_net: trying to use a different mask family"
 				" (eg. ipv4/ipv6mask or ipv6/ipv4mask)\n");
@@ -58,6 +62,18 @@ struct net* mk_net(struct ip_addr* ip, struct ip_addr* mask)
 	}
 	n->ip=*ip;
 	n->mask=*mask;
+	for (r=0; r<n->ip.len/4; r++) { /*ipv4 & ipv6 addresses are multiple of 4*/
+		n->ip.u.addr32[r] &= n->mask.u.addr32[r];
+		if (n->ip.u.addr32[r]!=ip->u.addr32[r]) warning=1;
+	};
+	if (warning){
+		LOG(L_WARN, "WARNING: mk_net: invalid network address/netmask "
+					"combination fixed...\n");
+		print_ip("original network address:", ip, "/");
+		print_ip("", mask, "\n");
+		print_ip("fixed    network address:", &(n->ip), "/");
+		print_ip("", &(n->mask), "\n");
+	};
 	return n;
 error:
 	return 0;
@@ -67,26 +83,20 @@ error:
 
 struct net* mk_net_bitlen(struct ip_addr* ip, unsigned int bitlen)
 {
-	struct net* n;
+	struct ip_addr mask;
 	int r;
 	
 	if (bitlen>ip->len*8){
 		LOG(L_CRIT, "ERROR: mk_net_bitlen: bad bitlen number %d\n", bitlen);
 		goto error;
 	}
-	n=(struct net*)pkg_malloc(sizeof(struct net));
-	if (n==0){
-		LOG(L_CRIT, "ERROR: mk_net_bitlen: memory allocation failure\n"); 
-		goto error;
-	}
-	memset(n,0, sizeof(struct net));
-	n->ip=*ip;
-	for (r=0;r<bitlen/8;r++) n->mask.u.addr[r]=0xff;
-	if (bitlen%8) n->mask.u.addr[r]=  ~((1<<(8-(bitlen%8)))-1);
-	n->mask.af=ip->af;
-	n->mask.len=ip->len;
+	memset(&mask,0, sizeof(mask));
+	for (r=0;r<bitlen/8;r++) mask.u.addr[r]=0xff;
+	if (bitlen%8) mask.u.addr[r]=  ~((1<<(8-(bitlen%8)))-1);
+	mask.af=ip->af;
+	mask.len=ip->len;
 	
-	return n;
+	return mk_net(ip, &mask);
 error:
 	return 0;
 }

+ 11 - 1
modules/tm/t_reply.c

@@ -61,6 +61,7 @@
  *  2004-02-13: t->is_invite and t->local replaced with flags (bogdan)
  *  2004-02-18  fifo_t_reply imported from vm module (bogdan)
  *  2004-08-23  avp list is available from failure/on_reply routes (bogdan)
+ *  2004-10-01  added a new param.: restart_fr_on_each_reply (andrei)
  */
 
 
@@ -95,6 +96,10 @@
 #include "fix_lumps.h"
 #include "t_stats.h"
 
+
+/* restart fr timer on each provisional reply, default yes */
+int restart_fr_on_each_reply=1;
+
 /* are we processing original or shmemed request ? */
 enum route_mode rmode=MODE_REQUEST;
 
@@ -1186,6 +1191,7 @@ int reply_received( struct sip_msg  *p_msg )
 {
 
 	int msg_status;
+	int last_uac_status;
 	char *ack;
 	unsigned int ack_len;
 	int branch;
@@ -1212,6 +1218,7 @@ int reply_received( struct sip_msg  *p_msg )
 		"uac[%d]=%d local=%d is_invite=%d)\n",
 		t->uas.status, branch, uac->last_received, 
 		is_local(t), is_invite(t));
+	last_uac_status=uac->last_received;
 
 	/* it's a cancel ... ? */
 	if (get_cseq(p_msg)->method.len==CANCEL_LEN 
@@ -1291,7 +1298,10 @@ int reply_received( struct sip_msg  *p_msg )
 	} 
 
 	/* update FR/RETR timers on provisional replies */
-	if (msg_status<200) { /* provisional now */
+	if (msg_status<200 && ( restart_fr_on_each_reply ||
+				( (last_uac_status<msg_status) &&
+					((msg_status>=180) || (last_uac_status==0)) )
+			) ) { /* provisional now */
 		if (is_invite(t)) {
 			/* invite: change FR to longer FR_INV, do not
 			   attempt to restart retransmission any more

+ 3 - 0
modules/tm/t_reply.h

@@ -35,6 +35,9 @@
 
 #include "h_table.h"
 
+
+extern int restart_fr_on_each_reply;
+
 /* reply processing status */
 enum rps {
 	/* something bad happened */

+ 2 - 0
modules/tm/tm.c

@@ -71,6 +71,7 @@
  *              takes no parameters -> forwards to uri (bogdan)
  *  2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
  *  2004-02-18  t_reply exported via FIFO - imported from VM (bogdan)
+ *  2004-10-01  added a new param.: restart_fr_on_each_reply (andrei)
  */
 
 
@@ -265,6 +266,7 @@ static param_export_t params[]={
 	{"noisy_ctimer",          INT_PARAM, &noisy_ctimer                          },
 	{"uac_from",              STR_PARAM, &uac_from                              },
 	{"unix_tx_timeout",       INT_PARAM, &tm_unix_tx_timeout                    },
+	{"restart_fr_on_each_reply", INT_PARAM, &restart_fr_on_each_reply        },
 	{0,0,0}
 };