Bladeren bron

core: support for parsing the Call-Info header

* extend parsing Call-ID due to _call_ is the token detected
Victor Seva 8 jaren geleden
bovenliggende
commit
7815c38056

+ 37 - 0
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: */

+ 2 - 1
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;                  \
      }
 
 

+ 1 - 0
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:

+ 2 - 0
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)
 

+ 3 - 0
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 */

+ 4 - 0
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;

+ 2 - 0
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: