Răsfoiți Sursa

Function to retrieve the first URI from Path headers.

Signed-off-by: Jan Janak <[email protected]>
Daniel-Constantin Mierla 16 ani în urmă
părinte
comite
49e8baef34
2 a modificat fișierele cu 27 adăugiri și 0 ștergeri
  1. 26 0
      lib/kcore/parser_helpers.c
  2. 1 0
      lib/kcore/parser_helpers.h

+ 26 - 0
lib/kcore/parser_helpers.c

@@ -174,3 +174,29 @@ int print_rr_body(struct hdr_field *iroute, str *oroute, int order,
 error:
 	return -1;
 }
+
+
+/*!
+ * Path must be available. Function returns the first uri 
+ * from Path without any duplication.
+ */
+int get_path_dst_uri(str *_p, str *_dst)
+{
+	rr_t *route = 0;
+
+	LM_DBG("path for branch: '%.*s'\n", _p->len, _p->s);
+	if(parse_rr_body(_p->s, _p->len, &route) < 0) {	
+		LM_ERR("failed to parse Path body\n");
+		return -1;
+	}
+
+	if(!route) {
+		LM_ERR("failed to parse Path body no head found\n");
+		return -1;
+	}
+	*_dst = route->nameaddr.uri;
+
+	free_rr(&route);
+	
+	return 0;
+}

+ 1 - 0
lib/kcore/parser_helpers.h

@@ -17,5 +17,6 @@ struct sip_uri* parse_from_uri(struct sip_msg* msg);
 int print_rr_body(struct hdr_field *iroute, str *oroute, int order,
 				  unsigned int * nb_recs);
 
+int get_path_dst_uri(str *_p, str *_dst);
 
 #endif /* _PARSER_HELPERS_H */