diff --git a/src/core/parser/case_c_inf.h b/src/core/parser/case_c_inf.h new file mode 100644 index 00000000000..f6bfd3f9473 --- /dev/null +++ b/src/core/parser/case_c_inf.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2017 Victor Seva (sipwise.com) + * + * This file is part of Kamailio, a free SIP server. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/** Parser :: Call-Info Header Name Parsing Macros. + * @file + * + * @ingroup parser + */ +#ifndef __case_c_inf_h +#define __case_c_inf_h + +#define C_INFO_CASE \ + case __inf_: \ + hdr->type = HDR_CALLINFO_T; \ + p += 4; \ + if (LOWER_BYTE(*p) != 'o') goto other; \ + p++; \ + goto dc_end; + +#endif /*__case_c_inf_h*/ + +/* vi: set ts=4 sw=4 tw=79:ai:cindent: */ diff --git a/src/core/parser/case_call.h b/src/core/parser/case_call.h index fee225739c9..a0fbcebc4bd 100644 --- a/src/core/parser/case_call.h +++ b/src/core/parser/case_call.h @@ -31,7 +31,7 @@ #ifndef CASE_CALL_H #define CASE_CALL_H -#include "../comp_defs.h" +#include "case_c_inf.h" #define ID_CASE \ switch(LOWER_DWORD(val)) { \ @@ -44,6 +44,7 @@ hdr->type = HDR_CALLID_T; \ p += 4; \ goto dc_end; \ + C_INFO_CASE; \ } diff --git a/src/core/parser/hf.c b/src/core/parser/hf.c index ba0d5fb5196..5a78e76f264 100644 --- a/src/core/parser/hf.c +++ b/src/core/parser/hf.c @@ -193,6 +193,7 @@ void clean_hdr_field(struct hdr_field* const hf) case HDR_PATH_T: case HDR_PRIVACY_T: case HDR_REASON_T: + case HDR_CALLINFO_T: break; default: diff --git a/src/core/parser/hf.h b/src/core/parser/hf.h index 0dc25c95c23..0f25792852d 100644 --- a/src/core/parser/hf.h +++ b/src/core/parser/hf.h @@ -105,6 +105,7 @@ enum _hdr_types_t { HDR_PATH_T /*!< Path header field */, HDR_PRIVACY_T /*!< Privacy header field */, HDR_REASON_T /**< Reason header field */, + HDR_CALLINFO_T /*!< Call-Info header field*/, HDR_EOH_T /*!< End of message header */ }; @@ -178,6 +179,7 @@ typedef unsigned long long hdr_flags_t; #define HDR_PATH_F HDR_F_DEF(PATH) #define HDR_PRIVACY_F HDR_F_DEF(PRIVACY) #define HDR_REASON_F HDR_F_DEF(REASON) +#define HDR_CALLINFO_F HDR_F_DEF(CALLINFO) #define HDR_OTHER_F HDR_F_DEF(OTHER) diff --git a/src/core/parser/keys.h b/src/core/parser/keys.h index 6a93d5d2eee..322edc67c81 100644 --- a/src/core/parser/keys.h +++ b/src/core/parser/keys.h @@ -208,6 +208,9 @@ /* _iden_ is already defined */ /* _tity_ is already defined */ +/* _call_ is already defined */ +#define __inf_ 0x666e692d /* "-inf" */ + /*!} */ #endif /* KEYS_H */ diff --git a/src/core/parser/msg_parser.c b/src/core/parser/msg_parser.c index aaeb6425173..e8c990da9f9 100644 --- a/src/core/parser/msg_parser.c +++ b/src/core/parser/msg_parser.c @@ -241,6 +241,7 @@ char* get_hdr_field(char* const buf, char* const end, struct hdr_field* const hd case HDR_PAI_T: case HDR_PPI_T: case HDR_REASON_T: + case HDR_CALLINFO_T: case HDR_OTHER_T: /* just skip over it */ hdr->body.s=tmp; @@ -535,6 +536,9 @@ int parse_headers(struct sip_msg* const msg, const hdr_flags_t flags, const int case HDR_REASON_T: msg->parsed_flag|=HDR_REASON_F; break; + case HDR_CALLINFO_T: + msg->parsed_flag|=HDR_CALLINFO_F; + break; default: BUG("unknown header type %d\n", hf->type); goto error; diff --git a/src/core/sip_msg_clone.c b/src/core/sip_msg_clone.c index 048ef77959a..5279af42acb 100644 --- a/src/core/sip_msg_clone.c +++ b/src/core/sip_msg_clone.c @@ -480,6 +480,7 @@ struct sip_msg* sip_msg_shm_clone( struct sip_msg *org_msg, int *sip_msg_len, case HDR_PATH_T: case HDR_PRIVACY_T: case HDR_REASON_T: + case HDR_CALLINFO_T: /* we ignore them for now even if they have something parsed*/ break; }/*switch*/ @@ -631,6 +632,7 @@ struct sip_msg* sip_msg_shm_clone( struct sip_msg *org_msg, int *sip_msg_len, case HDR_IDENTITY_INFO_T: case HDR_RETRY_AFTER_T: case HDR_REASON_T: + case HDR_CALLINFO_T: break; case HDR_VIA_T: diff --git a/src/modules/sca/sca_call_info.c b/src/modules/sca/sca_call_info.c index 58213b3daf0..e42a20097f9 100644 --- a/src/modules/sca/sca_call_info.c +++ b/src/modules/sca/sca_call_info.c @@ -308,23 +308,6 @@ int sca_call_info_append_header_for_appearance_index(sca_subscription *sub, return (-1); } -hdr_field_t *sca_call_info_header_find(hdr_field_t *msg_hdrs) -{ - hdr_field_t *hdr = NULL; - - for (hdr = msg_hdrs; hdr != NULL; hdr = hdr->next) { - if (hdr->type == HDR_OTHER_T - && hdr->name.len == SCA_CALL_INFO_HEADER_NAME.len) { - if (strncasecmp(hdr->name.s, SCA_CALL_INFO_HEADER_NAME.s, - SCA_CALL_INFO_HEADER_NAME.len) == 0) { - break; - } - } - } - - return (hdr); -} - int sca_call_info_body_parse(str *hdr_body, sca_call_info *call_info) { str s = STR_NULL; @@ -485,23 +468,10 @@ static int sca_call_info_header_remove(sip_msg_t *msg) LM_ERR("Failed to parse_headers\n"); return (-1); } - -#ifdef notdef - for (hdr = sca_call_info_header_find(msg->headers); hdr != NULL; - hdr = sca_call_info_header_find(hdr->next)) { -#endif // notdef - for (hdr = msg->headers; hdr; hdr = hdr->next) { - if (hdr->name.len != SCA_CALL_INFO_HEADER_NAME.len) { - continue; - } - if (memcmp(hdr->name.s, SCA_CALL_INFO_HEADER_NAME.s, hdr->name.len) - != 0) { - continue; - } - + for (hdr = get_hdr(msg, HDR_CALLINFO_T); hdr; hdr = next_sibling_hdr(hdr)) { // del_lump takes packet, offset, lump length, & hdr type ci_hdr_lump = del_lump(msg, hdr->name.s - msg->buf, hdr->len, - HDR_OTHER_T); + HDR_CALLINFO_T); if (ci_hdr_lump == NULL) { LM_ERR("Failed to del_lump Call-Info header\n"); rc = -1; @@ -1883,7 +1853,7 @@ int sca_call_info_update(sip_msg_t *msg, char *p1, str *uri_to, str *uri_from) } memset(&call_info, 0, sizeof(sca_call_info)); - call_info_hdr = sca_call_info_header_find(msg->headers); + call_info_hdr = get_hdr(msg, HDR_CALLINFO_T); if (!SCA_HEADER_EMPTY(call_info_hdr)) { // this needs to accomodate comma-separated appearance info if (sca_call_info_body_parse(&call_info_hdr->body, &call_info) < 0) { diff --git a/src/modules/sca/sca_call_info.h b/src/modules/sca/sca_call_info.h index 0a2f04bee82..10714ea2a97 100644 --- a/src/modules/sca/sca_call_info.h +++ b/src/modules/sca/sca_call_info.h @@ -67,7 +67,6 @@ int sca_call_info_build_header(sca_mod *, sca_subscription *, char *, int); int sca_call_info_append_header_for_appearance_index(sca_subscription *, int, char *, int); -hdr_field_t *sca_call_info_header_find(hdr_field_t *); int sca_call_info_body_parse(str *, sca_call_info *); int sca_call_info_free(sca_call_info *); diff --git a/src/modules/sca/sca_subscribe.c b/src/modules/sca/sca_subscribe.c index e9fb461bfe3..48b0d58870b 100644 --- a/src/modules/sca/sca_subscribe.c +++ b/src/modules/sca/sca_subscribe.c @@ -1197,7 +1197,7 @@ int sca_handle_subscribe(sip_msg_t *msg, char *p1, char *p2) pkg_free(sub_key.s); if (req_sub.event == SCA_EVENT_TYPE_LINE_SEIZE) { - call_info_hdr = sca_call_info_header_find(msg->headers); + call_info_hdr = get_hdr(msg, HDR_CALLINFO_T); if (call_info_hdr) { if (sca_call_info_body_parse(&call_info_hdr->body, &call_info) < 0) {