Browse code

- code clean up

Daniel-Constantin Mierla authored on 11/06/2003 17:41:19
Showing 2 changed files
... ...
@@ -410,8 +410,6 @@ int xjab_manage_sipmsg(struct sip_msg *msg, int type)
410 410
 {
411 411
 	str body, dst, from_uri;
412 412
 	xj_sipmsg jsmsg;
413
-	struct to_body to;
414
-	struct sip_uri _uri;
415 413
 	int pipe, fl;
416 414
 	t_xj_jkey jkey, *p;
417 415
 
... ...
@@ -508,10 +506,10 @@ int xjab_manage_sipmsg(struct sip_msg *msg, int type)
508 506
 		goto prepare_job;
509 507
 	
510 508
 	// determination of destination
511
-	// - try to get first new_uri or r-uri, but check them against jdomain
512
-	// and aliases
509
+	// - try to get it from new_uri, r-uri or to hdr, but check it against
510
+	// jdomain and aliases
513 511
 	dst.len = 0;
514
-	if( msg->new_uri.len > 0 )
512
+	if( msg->new_uri.len > 0)
515 513
 	{
516 514
 		dst.s = msg->new_uri.s;
517 515
 		dst.len = msg->new_uri.len;
... ...
@@ -523,76 +521,31 @@ int xjab_manage_sipmsg(struct sip_msg *msg, int type)
523 521
 #endif
524 522
 	}
525 523
 	
526
-	if (dst.len == 0 &&  msg->first_line.u.request.uri.len > 0 )
524
+	if (dst.len == 0 &&  msg->first_line.u.request.uri.s != NULL
525
+			&& msg->first_line.u.request.uri.len > 0 )
527 526
 	{
527
+		dst.s = msg->first_line.u.request.uri.s;
528
+		dst.len = msg->first_line.u.request.uri.len;
529
+		if(xj_wlist_check_aliases(jwl, &dst))
530
+			dst.len = 0;
528 531
 #ifdef XJ_EXTRA_DEBUG
529
-		DBG("XJAB:xjab_manage_sipmsg: parsing URI from first line\n");
530
-#endif
531
-		if(parse_uri(msg->first_line.u.request.uri.s,
532
-					msg->first_line.u.request.uri.len, &_uri) < 0)
533
-		{
534
-			DBG("XJAB:xjab_manage_sipmsg: ERROR parsing URI from first line\n");
535
-			goto error;
536
-		}
537
-		if(_uri.user.len > 0)
538
-		{
539
-			dst.s = msg->first_line.u.request.uri.s;
540
-			dst.len = msg->first_line.u.request.uri.len;
541
-			if(xj_wlist_check_aliases(jwl, &dst))
542
-				dst.len = 0;
543
-#ifdef XJ_EXTRA_DEBUG
544
-			else
545
-				DBG("XJAB:xjab_manage_sipmsg: using URI for destination\n");
532
+		else
533
+			DBG("XJAB:xjab_manage_sipmsg: using R-URI for destination\n");
546 534
 #endif
547
-		}
548 535
 	}
549 536
 
550
-	if(dst.len == 0 && msg->to != NULL)
537
+	if(dst.len == 0 && msg->to->parsed)
551 538
 	{
552
-		if(msg->to->parsed)
553
-		{
554
-#ifdef XJ_EXTRA_DEBUG
555
-			DBG("XJAB:xjab_manage_sipmsg: TO already parsed\n");
556
-#endif
557
-			dst.s = ((struct to_body*)msg->to->parsed)->uri.s;
558
-			dst.len = ((struct to_body*)msg->to->parsed)->uri.len;
559
-			if(xj_wlist_check_aliases(jwl, &dst))
560
-				dst.len = 0;
539
+		dst.s = ((struct to_body*)msg->to->parsed)->uri.s;
540
+		dst.len = ((struct to_body*)msg->to->parsed)->uri.len;
541
+		if(dst.s == NULL || xj_wlist_check_aliases(jwl, &dst))
542
+			dst.len = 0;
561 543
 #ifdef XJ_EXTRA_DEBUG
562
-			else
563
-				DBG("XJAB:xjab_manage_sipmsg: using TO for destination\n");
564
-#endif
565
-		}
566 544
 		else
567
-		{
568
-#ifdef XJ_EXTRA_DEBUG
569
-			DBG("XJAB:xjab_manage_sipmsg: TO NOT parsed -> parsing ...\n");
570
-#endif
571
-			memset( &to , 0, sizeof(to) );
572
-			parse_to(msg->to->body.s, msg->to->body.s + msg->to->body.len + 1,
573
-				&to);
574
-			if(to.uri.len > 0) // to.error == PARSE_OK)
575
-			{
576
-#ifdef XJ_EXTRA_DEBUG
577
-				DBG("XJAB:xjab_manage_sipmsg: TO parsed OK <%.*s>.\n",
578
-					to.uri.len, to.uri.s);
579
-#endif
580
-				dst.s = to.uri.s;
581
-				dst.len = to.uri.len;
582
-				if(xj_wlist_check_aliases(jwl, &dst))
583
-					dst.len = 0;
584
-#ifdef XJ_EXTRA_DEBUG
585
-				else
586
-					DBG("XJAB:xjab_manage_sipmsg: using TO for destination\n");
545
+			DBG("XJAB:xjab_manage_sipmsg: using TO-URI for destination\n");
587 546
 #endif
588
-			}
589
-			else
590
-			{
591
-				DBG("XJAB:xjab_manage_sipmsg: error parsing TO header.\n");
592
-				goto error;
593
-			}
594
-		}
595 547
 	}
548
+	
596 549
 	if(dst.len == 0)
597 550
 	{
598 551
 		DBG("XJAB:xjab_manage_sipmsg: destination not found in SIP message\n");
... ...
@@ -33,6 +33,7 @@
33 33
  *
34 34
  * History
35 35
  * -------
36
+ * 2003-06-05  previously added macro replaced with 'xj_extract_aor', (dcm)
36 37
  * 2003-05-09  added macro for ajusting a SIP address, (dcm)
37 38
  */
38 39