summaryrefslogtreecommitdiff
path: root/src/hello/hello-ng.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/hello/hello-ng.c')
-rw-r--r--src/hello/hello-ng.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/hello/hello-ng.c b/src/hello/hello-ng.c
index c088abf35..2d60b04f3 100644
--- a/src/hello/hello-ng.c
+++ b/src/hello/hello-ng.c
@@ -194,3 +194,23 @@ GNUNET_HELLO_extract_address (const void *raw,
*nt = (enum GNUNET_NetworkType) raw_nt;
return GNUNET_strdup (raw_addr);
}
+
+
+/**
+ * Given an address as a string, extract the prefix that identifies
+ * the communicator offering transmissions to that address.
+ *
+ * @param address a peer's address
+ * @return NULL if the address is mal-formed, otherwise the prefix
+ */
+char *
+GNUNET_HELLO_address_to_prefix (const char *address)
+{
+ const char *dash;
+
+ dash = strchr (address, '-');
+ if (NULL == dash)
+ return NULL;
+ return GNUNET_strndup (address,
+ dash - address);
+}