Browse code

core: path_vec added to sip_msg structure

- basic path support in core (not yet for request forwarding functions)

Daniel-Constantin Mierla authored on 16/04/2009 10:14:37
Showing 2 changed files
... ...
@@ -698,6 +698,7 @@ void free_sip_msg(struct sip_msg* msg)
698 698
 {
699 699
 	if (msg->new_uri.s) { pkg_free(msg->new_uri.s); msg->new_uri.len=0; }
700 700
 	if (msg->dst_uri.s) { pkg_free(msg->dst_uri.s); msg->dst_uri.len=0; }
701
+	if (msg->path_vec.s) { pkg_free(msg->path_vec.s); msg->path_vec.len=0; }
701 702
 	if (msg->headers)     free_hdr_field_lst(msg->headers);
702 703
 	if (msg->body && msg->body->free) msg->body->free(&msg->body);
703 704
 	if (msg->add_rm)      free_lump_list(msg->add_rm);
... ...
@@ -750,6 +751,32 @@ void reset_dst_uri(struct sip_msg* msg)
750 751
 	msg->dst_uri.len = 0;
751 752
 }
752 753
 
754
+int set_path_vector(struct sip_msg* msg, str* path)
755
+{
756
+	char* ptr;
757
+
758
+	if (!msg || !path) {
759
+		LM_ERR("invalid parameter value\n");
760
+		return -1;
761
+	}
762
+
763
+	if (msg->path_vec.s && (msg->path_vec.len >= path->len)) {
764
+		memcpy(msg->path_vec.s, path->s, path->len);
765
+		msg->path_vec.len = path->len;
766
+	} else {
767
+		ptr = (char*)pkg_malloc(path->len);
768
+		if (!ptr) {
769
+			LM_ERR("not enough pkg memory\n");
770
+			return -1;
771
+		}
772
+
773
+		memcpy(ptr, path->s, path->len);
774
+		if (msg->path_vec.s) pkg_free(msg->path_vec.s);
775
+		msg->path_vec.s = ptr;
776
+		msg->path_vec.len = path->len;
777
+	}
778
+	return 0;
779
+}
753 780
 
754 781
 struct hdr_field* get_hdr(struct sip_msg *msg, enum _hdr_types_t ht)
755 782
 {
... ...
@@ -328,6 +328,7 @@ typedef struct sip_msg {
328 328
 	str set_global_port;
329 329
 	struct socket_info* force_send_socket; /* force sending on this socket,
330 330
 											  if ser */
331
+	str path_vec;
331 332
 } sip_msg_t;
332 333
 
333 334
 /* pointer to a fakes message which was never received ;
... ...
@@ -437,4 +438,5 @@ void reset_dst_uri(struct sip_msg* msg);
437 438
 struct hdr_field* get_hdr(struct sip_msg *msg, enum _hdr_types_t ht);
438 439
 struct hdr_field* next_sibling_hdr(struct hdr_field *hf);
439 440
 
441
+int set_path_vector(struct sip_msg* msg, str* path);
440 442
 #endif