Browse code

pv: use parsed uri to compute tosocket

(cherry picked from commit dc9531affae6336ea3771792a80385de56205ff0)

lazedo authored on 05/03/2019 10:29:39 • Henning Westerholt committed on 09/03/2019 11:56:30
Showing 1 changed files
... ...
@@ -1389,29 +1389,24 @@ int tr_eval_uri(struct sip_msg *msg, tr_param_t *tp, int subtype,
1389 1389
 			}
1390 1390
 			break;
1391 1391
 		case TR_URI_TOSOCKET:
1392
-			if(msg==NULL) {
1392
+			if(get_valid_proto_string(_tr_parsed_uri.proto, 1, 0, &sproto)<0) {
1393
+				LM_WARN("unknown transport protocol\n");
1394
+				val->rs = _tr_empty;
1395
+				break;
1396
+			}
1397
+			tr_set_crt_buffer();
1398
+			val->rs.len = snprintf(_tr_buffer, TR_BUFFER_SIZE,
1399
+					"%.*s:%.*s:%d", sproto.len, sproto.s,
1400
+					_tr_parsed_uri.host.len, _tr_parsed_uri.host.s,
1401
+					(_tr_parsed_uri.port_no!=0)
1402
+							?(int)_tr_parsed_uri.port_no:5060);
1403
+			if(val->rs.len<=0 || val->rs.len>=TR_BUFFER_SIZE) {
1404
+				LM_WARN("error converting uri to socket address [%.*s]\n",
1405
+						_tr_uri.len, _tr_uri.s);
1393 1406
 				val->rs = _tr_empty;
1394 1407
 				break;
1395
-			} else {
1396
-				if(get_valid_proto_string(msg->rcv.proto, 1, 0, &sproto)<0) {
1397
-					LM_WARN("unknown transport protocol\n");
1398
-					val->rs = _tr_empty;
1399
-					break;
1400
-				}
1401
-				tr_set_crt_buffer();
1402
-				val->rs.len = snprintf(_tr_buffer, TR_BUFFER_SIZE,
1403
-						"%.*s:%.*s:%d", sproto.len, sproto.s,
1404
-						_tr_parsed_uri.host.len, _tr_parsed_uri.host.s,
1405
-						(_tr_parsed_uri.port_no!=0)
1406
-								?(int)_tr_parsed_uri.port_no:5060);
1407
-				if(val->rs.len<=0 || val->rs.len>=TR_BUFFER_SIZE) {
1408
-					LM_WARN("error converting uri to socket address [%.*s]\n",
1409
-							_tr_uri.len, _tr_uri.s);
1410
-					val->rs = _tr_empty;
1411
-					break;
1412
-				}
1413
-				val->rs.s = _tr_buffer;
1414 1408
 			}
1409
+			val->rs.s = _tr_buffer;
1415 1410
 			break;
1416 1411
 		default:
1417 1412
 			LM_ERR("unknown subtype %d\n",
... ...
@@ -2684,7 +2679,7 @@ char* tr_parse_uri(str* in, trans_t *t)
2684 2679
 	} else if(name.len==6 && strncasecmp(name.s, "scheme", 6)==0) {
2685 2680
 		t->subtype = TR_URI_SCHEME;
2686 2681
 		goto done;
2687
-	} else if(name.len==6 && strncasecmp(name.s, "tosocket", 8)==0) {
2682
+	} else if(name.len==8 && strncasecmp(name.s, "tosocket", 8)==0) {
2688 2683
 		t->subtype = TR_URI_TOSOCKET;
2689 2684
 		goto done;
2690 2685
 	}