Module: kamailio
Branch: master
Commit: 5dab8768efb3bc8214c46005520c92c6d735ba39
URL:
https://github.com/kamailio/kamailio/commit/5dab8768efb3bc8214c46005520c92c…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-11-24T13:09:23+01:00
core/parser/contact: helper function to parse all contact headers
---
Modified: src/core/parser/contact/parse_contact.c
Modified: src/core/parser/contact/parse_contact.h
---
Diff:
https://github.com/kamailio/kamailio/commit/5dab8768efb3bc8214c46005520c92c…
Patch:
https://github.com/kamailio/kamailio/commit/5dab8768efb3bc8214c46005520c92c…
---
diff --git a/src/core/parser/contact/parse_contact.c
b/src/core/parser/contact/parse_contact.c
index af0cd39c2c..37a075a17d 100644
--- a/src/core/parser/contact/parse_contact.c
+++ b/src/core/parser/contact/parse_contact.c
@@ -226,3 +226,31 @@ int contact_iterator(contact_t** c, struct sip_msg* msg, contact_t*
prev)
return 0;
}
}
+
+/**
+ *
+ */
+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;
+}
diff --git a/src/core/parser/contact/parse_contact.h
b/src/core/parser/contact/parse_contact.h
index 36389b5e06..4d8e1cd642 100644
--- a/src/core/parser/contact/parse_contact.h
+++ b/src/core/parser/contact/parse_contact.h
@@ -70,5 +70,9 @@ void print_contact(FILE* _o, contact_body_t* _c);
*/
int contact_iterator(contact_t** c, struct sip_msg* msg, contact_t* prev);
+/*
+ * parse all Contact headers
+ */
+int parse_contact_headers(sip_msg_t *msg);
#endif /* PARSE_CONTACT_H */