Kaynağa Gözat

core: parser - backport of parse_contact_headers()

Daniel-Constantin Mierla 3 yıl önce
ebeveyn
işleme
adf9eb3d8d

+ 27 - 0
src/core/parser/contact/parse_contact.c

@@ -61,6 +61,33 @@ static inline int contact_parser(char* _s, int _l, contact_body_t* _c)
 	return 0;
 }
 
+/**
+ * Parse all contact headers
+ */
+int parse_contact_headers(sip_msg_t *msg)
+{
+	hdr_field_t* hdr;
+
+	if (parse_headers(msg, HDR_EOH_F, 0) < 0) {
+		LM_ERR("failed to parse headers\n");
+		return -1;
+	}
+
+	if (msg->contact) {
+		hdr = msg->contact;
+		while(hdr) {
+			if (hdr->type == HDR_CONTACT_T) {
+				if (!hdr->parsed && (parse_contact(hdr) < 0)) {
+					LM_ERR("failed to parse Contact body\n");
+					return -1;
+				}
+			}
+			hdr = hdr->next;
+		}
+	}
+
+	return 0;
+}
 
 /*
  * Parse contact header field body

+ 6 - 0
src/core/parser/contact/parse_contact.h

@@ -46,6 +46,12 @@ typedef struct contact_body {
 } contact_body_t;
 
 
+/**
+ * Parse all contact headers
+ */
+int parse_contact_headers(sip_msg_t *msg);
+
+
 /*
  * Parse contact header field body
  */