浏览代码

core: parser - helper functions to parse all record-/route headers

Daniel-Constantin Mierla 3 年之前
父节点
当前提交
22b8ecc244
共有 2 个文件被更改,包括 49 次插入0 次删除
  1. 46 0
      src/core/parser/parse_rr.c
  2. 3 0
      src/core/parser/parse_rr.h

+ 46 - 0
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;
+}

+ 3 - 0
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 */