Module: sip-router
Branch: master
Commit: d752afff9924e66da382a9dea48984761ad52b7f
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d752aff…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Thu Apr 16 12:14:37 2009 +0200
core: path_vec added to sip_msg structure
- basic path support in core (not yet for request forwarding functions)
---
parser/msg_parser.c | 27 +++++++++++++++++++++++++++
parser/msg_parser.h | 2 ++
2 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/parser/msg_parser.c b/parser/msg_parser.c
index 23201c5..5132112 100644
--- a/parser/msg_parser.c
+++ b/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->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->body && msg->body->free)
msg->body->free(&msg->body);
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;
}
+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)
{
diff --git a/parser/msg_parser.h b/parser/msg_parser.h
index 8624035..dd1b327 100644
--- a/parser/msg_parser.h
+++ b/parser/msg_parser.h
@@ -328,6 +328,7 @@ typedef struct sip_msg {
str set_global_port;
struct socket_info* force_send_socket; /* force sending on this socket,
if ser */
+ str path_vec;
} sip_msg_t;
/* 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* next_sibling_hdr(struct hdr_field *hf);
+int set_path_vector(struct sip_msg* msg, str* path);
#endif