Module: sip-router Branch: sr_3.0 Commit: 2163a7f7706a70c44faef18d08a89dbc960bfd47 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2163a7f7...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Juha Heinanen jh@tutpro.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 (cherry picked from commit 78f069c3726085902101a55d3bb98f0be7549b60)
---
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 0388bd4..a3531e2 100644 --- a/parser/msg_parser.c +++ b/parser/msg_parser.c @@ -243,6 +243,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; @@ -528,6 +530,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); } } +