Module: sip-router
Branch: master
Commit: cf9269d7315e2965dcb57afda7838c4a5d3ad807
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=cf9269d…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Fri Mar 23 12:51:35 2012 +0100
core: parser - helper functions to test msg context id
- use (msg id, pid) to identify the message context id
- to be used for matching the message context when caching values are
stored per it
- reported by Klaus Darilion for $TV(...)
---
parser/msg_parser.c | 26 ++++++++++++++++++++++++++
parser/msg_parser.h | 20 ++++++++++++++++++++
2 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/parser/msg_parser.c b/parser/msg_parser.c
index 73a86cf..fdbbd09 100644
--- a/parser/msg_parser.c
+++ b/parser/msg_parser.c
@@ -871,3 +871,29 @@ hdr_field_t* next_sibling_hdr_by_name(hdr_field_t *hf)
}
return NULL;
}
+
+/**
+ * set msg context id
+ * - return: -1 on error; 0 - on set
+ */
+int msg_ctx_id_set(sip_msg_t *msg, msg_ctx_id_t *mid)
+{
+ if(msg==NULL || mid==NULL)
+ return -1;
+ mid->msgid = msg->id;
+ mid->pid = msg->pid;
+ return 0;
+}
+
+/**
+ * check msg context id
+ * - return: -1 on error; 0 - on no match; 1 - on match
+ */
+int msg_ctx_id_match(sip_msg_t *msg, msg_ctx_id_t *mid)
+{
+ if(msg==NULL || mid==NULL)
+ return -1;
+ if(msg->id != mid->msgid || msg->pid!=mid->pid)
+ return 0;
+ return 1;
+}
diff --git a/parser/msg_parser.h b/parser/msg_parser.h
index ce71a44..cf78326 100644
--- a/parser/msg_parser.h
+++ b/parser/msg_parser.h
@@ -461,5 +461,25 @@ void reset_path_vector(struct sip_msg* msg);
/** reset a previously forced send socket. */
#define reset_force_socket(msg) set_force_socket(msg, 0)
+/**
+ * struct to identify a msg context
+ * - the pair of pid and message-id
+ */
+typedef struct msg_ctx_id {
+ int pid;
+ int msgid;
+} msg_ctx_id_t;
+
+/**
+ * set msg context id
+ * - return: -1 on error; 0 - on set
+ */
+int msg_ctx_id_set(sip_msg_t *msg, msg_ctx_id_t *mid);
+
+/**
+ * check msg context id
+ * - return: -1 on error; 0 - on no match; 1 - on match
+ */
+int msg_ctx_id_match(sip_msg_t *msg, msg_ctx_id_t *mid);
#endif