[SR-Dev] git:master: New functions that can be used to search for a header with given type

Jan Janak jan at iptel.org
Mon Mar 23 11:09:20 CET 2009


Module: sip-router
Branch: master
Commit: 7b878801737e7f368a22b1adcc1f2c05b9e8585a
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=7b878801737e7f368a22b1adcc1f2c05b9e8585a

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Jan Janak <jan at iptel.org>
Date:   Fri Mar 20 16:42:26 2009 +0100

New functions that can be used to search for a header with given type

This patch adds two new functions to the sip-router core. Function
get_hdr can be used to find the first occurrence of header with a given
type in a sip message if the particular header type does not have its
own hook in the sip_msg data structure.

The second function next_sibling_hdr can be used to find the next
occurence of header with the same type as the header in parameter
in the sip message.

Signed-off-by: Jan Janak <jan at iptel.org>

---

 parser/msg_parser.c |   22 ++++++++++++++++++++++
 parser/msg_parser.h |    3 +++
 2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/parser/msg_parser.c b/parser/msg_parser.c
index cad8028..74f91f5 100644
--- a/parser/msg_parser.c
+++ b/parser/msg_parser.c
@@ -743,3 +743,25 @@ void reset_dst_uri(struct sip_msg* msg)
 	msg->dst_uri.s = 0;
 	msg->dst_uri.len = 0;
 }
+
+
+struct hdr_field* get_hdr(struct sip_msg *msg, enum _hdr_types_t ht)
+{
+	struct hdr_field *hdr;
+
+	for(hdr = msg->headers; hdr; hdr = hdr->next) {
+		if(hdr->type == ht) return hdr;
+	}
+	return NULL;
+}
+
+
+struct hdr_field* next_sibling_hdr(struct hdr_field *hf)
+{	
+	struct hdr_field *hdr;
+	
+	for(hdr = hf->next; hdr; hdr = hdr->next) {
+		if(hdr->type == hf->type) return hdr;
+	}
+	return NULL;
+}
diff --git a/parser/msg_parser.h b/parser/msg_parser.h
index 48790c9..624c2ab 100644
--- a/parser/msg_parser.h
+++ b/parser/msg_parser.h
@@ -411,4 +411,7 @@ int set_dst_uri(struct sip_msg* msg, str* uri);
 /* If the dst_uri is set to an URI then reset it */
 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);
+
 #endif




More information about the sr-dev mailing list