[sr-dev] git:master:b3f59ded: core: keep references to proto and port parts by parse_protohostport()

Daniel-Constantin Mierla miconda at gmail.com
Wed Mar 30 08:41:14 CEST 2022


Module: kamailio
Branch: master
Commit: b3f59ded7d5ea9b183e4d301ca2a69aaeb966e65
URL: https://github.com/kamailio/kamailio/commit/b3f59ded7d5ea9b183e4d301ca2a69aaeb966e65

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2022-03-30T08:26:32+02:00

core: keep references to proto and port parts by parse_protohostport()

---

Modified: src/core/socket_info.c
Modified: src/core/socket_info.h

---

Diff:  https://github.com/kamailio/kamailio/commit/b3f59ded7d5ea9b183e4d301ca2a69aaeb966e65.diff
Patch: https://github.com/kamailio/kamailio/commit/b3f59ded7d5ea9b183e4d301ca2a69aaeb966e65.patch

---

diff --git a/src/core/socket_info.c b/src/core/socket_info.c
index 00d7bdf289..500945a22a 100644
--- a/src/core/socket_info.c
+++ b/src/core/socket_info.c
@@ -2271,11 +2271,14 @@ int parse_protohostport(str* ins, sr_phostp_t *r)
 	if (second) { /* 2 ':' found => check if valid */
 		if (parse_proto((unsigned char*)ins->s, first-ins->s, &r->proto)<0)
 			goto error_proto;
+		r->sproto.s = ins->s;
+		r->sproto.len = first-ins->s;
 
 		tmp.s=second+1;
 		tmp.len=(ins->s + ins->len) - tmp.s;
 
 		if (str2int(&tmp, (unsigned int *)&(r->port))<0) goto error_port;
+		r->sport = tmp;
 
 		r->host.s=first+1;
 		r->host.len=(int)(second-r->host.s);
@@ -2288,10 +2291,13 @@ int parse_protohostport(str* ins, sr_phostp_t *r)
 		/* invalid port => it's proto:host */
 		if (parse_proto((unsigned char*)ins->s, first-ins->s, &r->proto)<0)
 			goto error_proto;
+		r->sproto.s = ins->s;
+		r->sproto.len = first-ins->s;
 		r->host.s=first+1;
 		r->host.len=(int)(p-r->host.s);
 	}else{
 		/* valid port => its host:port */
+		r->sport = tmp;
 		r->host.s=ins->s;
 		r->host.len=(int)(first-r->host.s);
 	}
diff --git a/src/core/socket_info.h b/src/core/socket_info.h
index 4bf7b3e96c..50e4a063c1 100644
--- a/src/core/socket_info.h
+++ b/src/core/socket_info.h
@@ -151,8 +151,10 @@ inline static struct socket_info* get_first_socket(void)
 
 /* structure to break down 'proto:host:port' */
 typedef struct _sr_phostp {
+	str sproto;
 	int proto;
 	str host;
+	str sport;
 	int port;
 } sr_phostp_t;
 




More information about the sr-dev mailing list