Browse code

core/parser/contact: helper function to parse all contact headers

Daniel-Constantin Mierla authored on 24/11/2020 12:09:23
Showing 2 changed files
... ...
@@ -226,3 +226,31 @@ int contact_iterator(contact_t** c, struct sip_msg* msg, contact_t* prev)
226 226
 		return 0;
227 227
 	}
228 228
 }
229
+
230
+/**
231
+ *
232
+ */
233
+int parse_contact_headers(sip_msg_t *msg)
234
+{
235
+	hdr_field_t* hdr;
236
+
237
+	if (parse_headers(msg, HDR_EOH_F, 0) < 0) {
238
+		LM_ERR("failed to parse headers\n");
239
+		return -1;
240
+	}
241
+
242
+	if (msg->contact) {
243
+		hdr = msg->contact;
244
+		while(hdr) {
245
+			if (hdr->type == HDR_CONTACT_T) {
246
+				if (!hdr->parsed && (parse_contact(hdr) < 0)) {
247
+					LM_ERR("failed to parse Contact body\n");
248
+					return -1;
249
+				}
250
+			}
251
+			hdr = hdr->next;
252
+		}
253
+	}
254
+
255
+	return 0;
256
+}
... ...
@@ -70,5 +70,9 @@ void print_contact(FILE* _o, contact_body_t* _c);
70 70
  */
71 71
 int contact_iterator(contact_t** c, struct sip_msg* msg, contact_t* prev);
72 72
 
73
+/*
74
+ * parse all Contact headers
75
+ */
76
+int parse_contact_headers(sip_msg_t *msg);
73 77
 
74 78
 #endif /* PARSE_CONTACT_H */