Browse code

dialog: formatting and logs adjustments

Daniel-Constantin Mierla authored on 20/07/2022 06:28:20
Showing 1 changed files
... ...
@@ -456,7 +456,9 @@ err:
456 456
 	return -1;
457 457
 }
458 458
 
459
-dlg_t * build_dlg_t_early(struct sip_msg *msg, struct dlg_cell * cell, int branch_id, str * rr_set){
459
+dlg_t * build_dlg_t_early(struct sip_msg *msg, struct dlg_cell * cell,
460
+		int branch_id, str * rr_set)
461
+{
460 462
 
461 463
 	dlg_t* td = NULL;
462 464
 	str cseq;
... ...
@@ -470,31 +472,33 @@ dlg_t * build_dlg_t_early(struct sip_msg *msg, struct dlg_cell * cell, int branc
470 472
 	unsigned int own_rr = 0, skip_recs = 0;
471 473
 
472 474
 	if (cell->state != DLG_STATE_UNCONFIRMED && cell->state != DLG_STATE_EARLY) {
473
-		LM_ERR("Invalid state for build_dlg_state: %d (only working for unconfirmed or early dialogs)\n", cell->state);
475
+		LM_ERR("invalid state for build_dlg_state: %d"
476
+				" (only working for unconfirmed or early dialogs)\n", cell->state);
474 477
 		goto error;
475 478
 	}
476 479
 
477 480
 	if (msg == NULL || msg->first_line.type != SIP_REPLY) {
478 481
 		if (!cell->t) {
479
-			LM_ERR("No Transaction associated\n");
482
+			LM_ERR("no transaction associated\n");
480 483
 			goto error;
481 484
 		}
482 485
 
483 486
 		if (branch_id <= 0 || branch_id > cell->t->nr_of_outgoings) {
484
-			LM_ERR("Invalid branch %d (%d branches in transaction)\n", branch_id, cell->t->nr_of_outgoings);
487
+			LM_ERR("invalid branch %d (%d branches in transaction)\n",
488
+					branch_id, cell->t->nr_of_outgoings);
485 489
 			goto error;
486 490
 		}
487 491
 		msg = msg;
488 492
 	}
489 493
 
490
-	if (!msg->contact && (parse_headers(msg,HDR_CONTACT_F,0)<0 
491
-	   || !msg->contact)) {
494
+	if (!msg->contact && (parse_headers(msg,HDR_CONTACT_F,0)<0
495
+				|| !msg->contact)) {
492 496
 		LM_ERR("bad sip message or missing Contact hdr\n");
493 497
 		goto error;
494 498
 	}
495 499
 
496 500
 	if ( parse_contact(msg->contact)<0 ||
497
-	((contact_body_t *)msg->contact->parsed)->contacts==NULL) {
501
+			((contact_body_t *)msg->contact->parsed)->contacts==NULL) {
498 502
 		LM_ERR("bad Contact HDR\n");
499 503
 		goto error;
500 504
 	}
... ...
@@ -504,7 +508,8 @@ dlg_t * build_dlg_t_early(struct sip_msg *msg, struct dlg_cell * cell, int branc
504 508
 	nuri.len = MAX_URI_SIZE;
505 509
 	duri.s = dbuf;
506 510
 	duri.len = 80;
507
-	if(uri_restore_rcv_alias(&((contact_body_t *)msg->contact->parsed)->contacts->uri, &nuri, &duri)<0) {
511
+	if(uri_restore_rcv_alias(&((contact_body_t *)msg->contact->parsed)->contacts->uri,
512
+				&nuri, &duri)<0) {
508 513
 		nuri.len = 0;
509 514
 		duri.len = 0;
510 515
 	}
... ...
@@ -525,27 +530,27 @@ dlg_t * build_dlg_t_early(struct sip_msg *msg, struct dlg_cell * cell, int branc
525 530
 	/*route set*/
526 531
 	if (msg->record_route) {
527 532
 		if (cell->t) {
528
-			LM_DBG("Transaction exists\n");
533
+			LM_DBG("transaction exists\n");
529 534
 			own_rr = (cell->t->flags&TM_UAC_FLAG_R2)?2:
530
-			   (cell->t->flags&TM_UAC_FLAG_RR)?1:0;	
535
+				(cell->t->flags&TM_UAC_FLAG_RR)?1:0;
531 536
 		} else {
532 537
 			own_rr = (msg->flags&TM_UAC_FLAG_R2)?2:
533
-			   (msg->flags&TM_UAC_FLAG_RR)?1:0;
538
+				(msg->flags&TM_UAC_FLAG_RR)?1:0;
534 539
 		}
535 540
 		skip_recs = cell->from_rr_nb + own_rr;
536 541
 
537
-		LM_DBG("Skipping %u records, %u of myself\n", skip_recs, own_rr);
542
+		LM_DBG("skipping %u records, %u of myself\n", skip_recs, own_rr);
538 543
 
539 544
 		if( print_rr_body(msg->record_route, rr_set, DLG_CALLEE_LEG,
540
-							&skip_recs) != 0 ){
545
+					&skip_recs) != 0 ){
541 546
 			LM_ERR("failed to print route records \n");
542 547
 			goto error;
543 548
 		}
544
-		LM_DBG("New Route-Set: %.*s\n", STR_FMT(rr_set));
549
+		LM_DBG("new route set: %.*s\n", STR_FMT(rr_set));
545 550
 
546 551
 		if( parse_rr_body(rr_set->s, rr_set->len,
547
-						&td->route_set) !=0){
548
-		 	LM_ERR("failed to parse route set\n");
552
+					&td->route_set) !=0){
553
+			LM_ERR("failed to parse route set\n");
549 554
 			goto error;
550 555
 		}
551 556
 	}
... ...
@@ -606,12 +611,13 @@ dlg_t * build_dlg_t_early(struct sip_msg *msg, struct dlg_cell * cell, int branc
606 611
 	return td;
607 612
 
608 613
 error:
609
-	LM_ERR("Error occured creating early dialog\n");	
614
+	LM_ERR("Error occured creating early dialog\n");
610 615
 	free_tm_dlg(td);
611 616
 	return NULL;
612 617
 }
613 618
 
614
-int dlg_request_within(struct sip_msg *msg, struct dlg_cell *dlg, int side, str * method, str * hdrs, str * content_type, str * content)
619
+int dlg_request_within(struct sip_msg *msg, struct dlg_cell *dlg, int side,
620
+		str * method, str * hdrs, str * content_type, str * content)
615 621
 {
616 622
 	uac_req_t uac_r;
617 623
 	dlg_t* dialog_info;
... ...
@@ -625,7 +631,8 @@ int dlg_request_within(struct sip_msg *msg, struct dlg_cell *dlg, int side, str
625 631
 	memset(rr_set_s, 0, 500);
626 632
 
627 633
 	/* Special treatment for callee in early state*/
628
-	if (dlg->state != DLG_STATE_CONFIRMED_NA && dlg->state != DLG_STATE_CONFIRMED && side == DLG_CALLEE_LEG) {
634
+	if (dlg->state != DLG_STATE_CONFIRMED_NA
635
+			&& dlg->state != DLG_STATE_CONFIRMED && side == DLG_CALLEE_LEG) {
629 636
 		LM_DBG("Send request to callee in early state...\n");
630 637
 
631 638
 		if (dlg->t == NULL && d_tmb.t_gett) {
... ...
@@ -649,7 +656,8 @@ int dlg_request_within(struct sip_msg *msg, struct dlg_cell *dlg, int side, str
649 656
 		}
650 657
 	}
651 658
 
652
-	LM_DBG("sending %.*s to %s\n", method->len, method->s, (side==DLG_CALLER_LEG)?"caller":"callee");
659
+	LM_DBG("sending %.*s to %s\n", method->len, method->s,
660
+			(side==DLG_CALLER_LEG)?"caller":"callee");
653 661
 
654 662
 	iuid = dlg_get_iuid_shm_clone(dlg);
655 663
 	if(iuid==NULL)
... ...
@@ -689,7 +697,8 @@ int dlg_request_within(struct sip_msg *msg, struct dlg_cell *dlg, int side, str
689 697
 		LM_DBG("All headers: %.*s\n", STR_FMT(&allheaders));
690 698
 	}
691 699
 
692
-	set_uac_req(&uac_r, method, allheaders.len?&allheaders:NULL, (content && content->len)?content:NULL, dialog_info, TMCB_LOCAL_COMPLETED,
700
+	set_uac_req(&uac_r, method, allheaders.len?&allheaders:NULL,
701
+			(content && content->len)?content:NULL, dialog_info, TMCB_LOCAL_COMPLETED,
693 702
 				bye_reply_cb, (void*)iuid);
694 703
 
695 704
 	result = d_tmb.t_request_within(&uac_r);
... ...
@@ -704,7 +713,8 @@ int dlg_request_within(struct sip_msg *msg, struct dlg_cell *dlg, int side, str
704 713
 
705 714
 	free_tm_dlg(dialog_info);
706 715
 
707
-	LM_DBG("%.*s sent to %s\n", method->len, method->s, (side==DLG_CALLER_LEG)?"caller":"callee");
716
+	LM_DBG("%.*s sent to %s\n", method->len, method->s,
717
+			(side==DLG_CALLER_LEG)?"caller":"callee");
708 718
 
709 719
 	return 0;
710 720
 err: