[sr-dev] git:kamailio_3.0: core: PAI and PPI parsing support fixed

Daniel-Constantin Mierla miconda at gmail.com
Sun Nov 1 14:07:38 CET 2009


Module: sip-router
Branch: kamailio_3.0
Commit: 78f069c3726085902101a55d3bb98f0be7549b60
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=78f069c3726085902101a55d3bb98f0be7549b60

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Sun Nov  1 14:06:04 2009 +0100

core: PAI and PPI parsing support fixed

- use a new function to identify hdr type instead of 'case' construct
- reported by Juha Heinanen

---

 parser/hf.c           |    9 +++++++++
 parser/msg_parser.c   |   10 ++++++++++
 parser/parse_hname2.c |   20 ++++++++++++++++++++
 3 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/parser/hf.c b/parser/hf.c
index a54865e..09fcc4a 100644
--- a/parser/hf.c
+++ b/parser/hf.c
@@ -216,6 +216,15 @@ void clean_hdr_field(struct hdr_field* hf)
 		case HDR_PATH_T:
 		case HDR_PRIVACY_T:
 			break;
+
+		case HDR_PPI_T:
+			free_to(hf->parsed);
+			break;
+
+		case HDR_PAI_T:
+			free_to(hf->parsed);
+			break;
+
 		default:
 			LOG(L_CRIT, "BUG: clean_hdr_field: unknown header type %d\n",
 			    hf->type);
diff --git a/parser/msg_parser.c b/parser/msg_parser.c
index d218b0b..e5cb7e6 100644
--- a/parser/msg_parser.c
+++ b/parser/msg_parser.c
@@ -244,6 +244,8 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
 		case HDR_PROXY_AUTHENTICATE_T:
 	    case HDR_PATH_T:
 	    case HDR_PRIVACY_T:
+	    case HDR_PAI_T:
+	    case HDR_PPI_T:
 		case HDR_OTHER_T:
 			/* just skip over it */
 			hdr->body.s=tmp;
@@ -530,6 +532,14 @@ int parse_headers(struct sip_msg* msg, hdr_flags_t flags, int next)
 				if (msg->privacy==0) msg->privacy=hf;
 				msg->parsed_flag|=HDR_PRIVACY_F;
 				break;
+		    case HDR_PAI_T:
+				if (msg->pai==0) msg->pai=hf;
+				msg->parsed_flag|=HDR_PAI_F;
+				break;
+		    case HDR_PPI_T:
+				if (msg->ppi==0) msg->ppi=hf;
+				msg->parsed_flag|=HDR_PPI_F;
+				break;
 			default:
 				LOG(L_CRIT, "BUG: parse_headers: unknown header type %d\n",
 							hf->type);
diff --git a/parser/parse_hname2.c b/parser/parse_hname2.c
index 2b4152a..f94a30d 100644
--- a/parser/parse_hname2.c
+++ b/parser/parse_hname2.c
@@ -163,6 +163,24 @@ static inline char* skip_ws(char* p, unsigned int size)
         }
 
 
+int hdr_update_type(struct hdr_field* hdr)
+{
+	if(hdr==0 || hdr->name.s==0)
+		return -1;
+	switch(hdr->name.len) {
+		case 19:
+			if(strncasecmp(hdr->name.s, "P-Asserted-Identity", 19)==0)
+				hdr->type = HDR_PAI_T;
+		break;
+		case 20:
+			if(strncasecmp(hdr->name.s, "P-Preferred-Identity", 20)==0)
+				hdr->type = HDR_PPI_T;
+		break;
+	}
+
+	return 0;
+}
+
 char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
 {
 	register char* p;
@@ -242,6 +260,8 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
 	} else {
 		hdr->type = HDR_OTHER_T;
 		hdr->name.len = p - hdr->name.s;
+		hdr_update_type(hdr);
 		return (p + 1);
 	}
 }
+




More information about the sr-dev mailing list