Module: kamailio
Branch: master
Commit: 22b8ecc24442dce775600dfb186a83bc947fd4ca
URL:
https://github.com/kamailio/kamailio/commit/22b8ecc24442dce775600dfb186a83b…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2022-03-14T12:17:42+01:00
core: parser - helper functions to parse all record-/route headers
---
Modified: src/core/parser/parse_rr.c
Modified: src/core/parser/parse_rr.h
---
Diff:
https://github.com/kamailio/kamailio/commit/22b8ecc24442dce775600dfb186a83b…
Patch:
https://github.com/kamailio/kamailio/commit/22b8ecc24442dce775600dfb186a83b…
---
diff --git a/src/core/parser/parse_rr.c b/src/core/parser/parse_rr.c
index 9557bffc9b..e8854cbd4b 100644
--- a/src/core/parser/parse_rr.c
+++ b/src/core/parser/parse_rr.c
@@ -494,3 +494,49 @@ int get_path_dst_uri(str *_p, str *_dst)
return 0;
}
+
+/*!
+ * Parse all Record-Route header
+ */
+int parse_record_route_headers(sip_msg_t *msg)
+{
+ hdr_field_t *hf;
+ if(parse_headers(msg, HDR_EOH_F, 0) < 0) {
+ LM_ERR("failed to parse the headers\n");
+ return -1;
+ }
+
+ hf = msg->record_route;
+ while(hf) {
+ if (parse_rr(hf) < 0) {
+ LM_ERR("failed to parse Record-Route\n");
+ return -1;
+ }
+
+ hf = next_sibling_hdr(hf);
+ }
+ return 0;
+}
+
+/*!
+ * Parse all Route header
+ */
+int parse_route_headers(sip_msg_t *msg)
+{
+ hdr_field_t *hf;
+ if(parse_headers(msg, HDR_EOH_F, 0) < 0) {
+ LM_ERR("failed to parse the headers\n");
+ return -1;
+ }
+
+ hf = msg->route;
+ while(hf) {
+ if (parse_rr(hf) < 0) {
+ LM_ERR("failed to parse Record-Route\n");
+ return -1;
+ }
+
+ hf = next_sibling_hdr(hf);
+ }
+ return 0;
+}
diff --git a/src/core/parser/parse_rr.h b/src/core/parser/parse_rr.h
index f7379a6035..7c38a2d38d 100644
--- a/src/core/parser/parse_rr.h
+++ b/src/core/parser/parse_rr.h
@@ -180,4 +180,7 @@ int print_rr_body(struct hdr_field *iroute, str *oroute, int order,
int get_path_dst_uri(str *_p, str *_dst);
+int parse_record_route_headers(sip_msg_t *msg);
+int parse_route_headers(sip_msg_t *msg);
+
#endif /* PARSE_RR_H */