Browse code

core: parser - backport of parse_contact_headers()

Daniel-Constantin Mierla authored on 15/09/2022 11:36:18
Showing 2 changed files
... ...
@@ -61,6 +61,33 @@ static inline int contact_parser(char* _s, int _l, contact_body_t* _c)
61 61
 	return 0;
62 62
 }
63 63
 
64
+/**
65
+ * Parse all contact headers
66
+ */
67
+int parse_contact_headers(sip_msg_t *msg)
68
+{
69
+	hdr_field_t* hdr;
70
+
71
+	if (parse_headers(msg, HDR_EOH_F, 0) < 0) {
72
+		LM_ERR("failed to parse headers\n");
73
+		return -1;
74
+	}
75
+
76
+	if (msg->contact) {
77
+		hdr = msg->contact;
78
+		while(hdr) {
79
+			if (hdr->type == HDR_CONTACT_T) {
80
+				if (!hdr->parsed && (parse_contact(hdr) < 0)) {
81
+					LM_ERR("failed to parse Contact body\n");
82
+					return -1;
83
+				}
84
+			}
85
+			hdr = hdr->next;
86
+		}
87
+	}
88
+
89
+	return 0;
90
+}
64 91
 
65 92
 /*
66 93
  * Parse contact header field body
... ...
@@ -46,6 +46,12 @@ typedef struct contact_body {
46 46
 } contact_body_t;
47 47
 
48 48
 
49
+/**
50
+ * Parse all contact headers
51
+ */
52
+int parse_contact_headers(sip_msg_t *msg);
53
+
54
+
49 55
 /*
50 56
  * Parse contact header field body
51 57
  */