Browse Source

core: path_vec added to sip_msg structure

- basic path support in core (not yet for request forwarding functions)
Daniel-Constantin Mierla 16 years ago
parent
commit
d752afff99
2 changed files with 29 additions and 0 deletions
  1. 27 0
      parser/msg_parser.c
  2. 2 0
      parser/msg_parser.h

+ 27 - 0
parser/msg_parser.c

@@ -698,6 +698,7 @@ void free_sip_msg(struct sip_msg* msg)
 {
 {
 	if (msg->new_uri.s) { pkg_free(msg->new_uri.s); msg->new_uri.len=0; }
 	if (msg->new_uri.s) { pkg_free(msg->new_uri.s); msg->new_uri.len=0; }
 	if (msg->dst_uri.s) { pkg_free(msg->dst_uri.s); msg->dst_uri.len=0; }
 	if (msg->dst_uri.s) { pkg_free(msg->dst_uri.s); msg->dst_uri.len=0; }
+	if (msg->path_vec.s) { pkg_free(msg->path_vec.s); msg->path_vec.len=0; }
 	if (msg->headers)     free_hdr_field_lst(msg->headers);
 	if (msg->headers)     free_hdr_field_lst(msg->headers);
 	if (msg->body && msg->body->free) msg->body->free(&msg->body);
 	if (msg->body && msg->body->free) msg->body->free(&msg->body);
 	if (msg->add_rm)      free_lump_list(msg->add_rm);
 	if (msg->add_rm)      free_lump_list(msg->add_rm);
@@ -750,6 +751,32 @@ void reset_dst_uri(struct sip_msg* msg)
 	msg->dst_uri.len = 0;
 	msg->dst_uri.len = 0;
 }
 }
 
 
+int set_path_vector(struct sip_msg* msg, str* path)
+{
+	char* ptr;
+
+	if (!msg || !path) {
+		LM_ERR("invalid parameter value\n");
+		return -1;
+	}
+
+	if (msg->path_vec.s && (msg->path_vec.len >= path->len)) {
+		memcpy(msg->path_vec.s, path->s, path->len);
+		msg->path_vec.len = path->len;
+	} else {
+		ptr = (char*)pkg_malloc(path->len);
+		if (!ptr) {
+			LM_ERR("not enough pkg memory\n");
+			return -1;
+		}
+
+		memcpy(ptr, path->s, path->len);
+		if (msg->path_vec.s) pkg_free(msg->path_vec.s);
+		msg->path_vec.s = ptr;
+		msg->path_vec.len = path->len;
+	}
+	return 0;
+}
 
 
 struct hdr_field* get_hdr(struct sip_msg *msg, enum _hdr_types_t ht)
 struct hdr_field* get_hdr(struct sip_msg *msg, enum _hdr_types_t ht)
 {
 {

+ 2 - 0
parser/msg_parser.h

@@ -328,6 +328,7 @@ typedef struct sip_msg {
 	str set_global_port;
 	str set_global_port;
 	struct socket_info* force_send_socket; /* force sending on this socket,
 	struct socket_info* force_send_socket; /* force sending on this socket,
 											  if ser */
 											  if ser */
+	str path_vec;
 } sip_msg_t;
 } sip_msg_t;
 
 
 /* pointer to a fakes message which was never received ;
 /* pointer to a fakes message which was never received ;
@@ -437,4 +438,5 @@ void reset_dst_uri(struct sip_msg* msg);
 struct hdr_field* get_hdr(struct sip_msg *msg, enum _hdr_types_t ht);
 struct hdr_field* get_hdr(struct sip_msg *msg, enum _hdr_types_t ht);
 struct hdr_field* next_sibling_hdr(struct hdr_field *hf);
 struct hdr_field* next_sibling_hdr(struct hdr_field *hf);
 
 
+int set_path_vector(struct sip_msg* msg, str* path);
 #endif
 #endif