aboutsummaryrefslogtreecommitdiff
path: root/src/hello
diff options
context:
space:
mode:
Diffstat (limited to 'src/hello')
-rw-r--r--src/hello/Makefile.am5
-rw-r--r--src/hello/Makefile.in142
-rw-r--r--src/hello/address.c2
-rw-r--r--src/hello/gnunet-hello.c4
-rw-r--r--src/hello/hello.c357
-rw-r--r--src/hello/test_hello.c71
6 files changed, 479 insertions, 102 deletions
diff --git a/src/hello/Makefile.am b/src/hello/Makefile.am
index 26aa6c7..fd5a41b 100644
--- a/src/hello/Makefile.am
+++ b/src/hello/Makefile.am
@@ -14,10 +14,11 @@ lib_LTLIBRARIES = libgnunethello.la
libgnunethello_la_SOURCES = \
hello.c address.c
libgnunethello_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la $(XLIB)
+ $(top_builddir)/src/util/libgnunetutil.la $(XLIB) \
+ $(LTLIBINTL)
libgnunethello_la_LDFLAGS = \
$(GN_LIB_LDFLAGS) \
- -version-info 0:0:0
+ -version-info 1:0:1
noinst_PROGRAMS = \
gnunet-hello
diff --git a/src/hello/Makefile.in b/src/hello/Makefile.in
index 1887b27..f99eca2 100644
--- a/src/hello/Makefile.in
+++ b/src/hello/Makefile.in
@@ -1,9 +1,9 @@
-# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# Makefile.in generated by automake 1.11.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
-# Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -17,6 +17,23 @@
VPATH = @srcdir@
+am__make_dryrun = \
+ { \
+ am__dry=no; \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
+ | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+ *) \
+ for am__flg in $$MAKEFLAGS; do \
+ case $$am__flg in \
+ *=*|--*) ;; \
+ *n*) am__dry=yes; break;; \
+ esac; \
+ done;; \
+ esac; \
+ test $$am__dry = yes; \
+ }
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@@ -43,14 +60,15 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/absolute-header.m4 \
$(top_srcdir)/m4/align.m4 $(top_srcdir)/m4/argz.m4 \
- $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/iconv.m4 \
- $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libcurl.m4 \
- $(top_srcdir)/m4/libgcrypt.m4 $(top_srcdir)/m4/libtool.m4 \
- $(top_srcdir)/m4/libunistring.m4 $(top_srcdir)/m4/ltdl.m4 \
- $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
- $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
- $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \
+ $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/glib-2.0.m4 \
+ $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \
+ $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+ $(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libgcrypt.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/libunistring.m4 \
+ $(top_srcdir)/m4/ltdl.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \
$(top_srcdir)/m4/progtest.m4 $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@@ -80,16 +98,22 @@ am__nobase_list = $(am__nobase_strip_setup); \
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
am__installdirs = "$(DESTDIR)$(libdir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
am__DEPENDENCIES_1 =
libgnunethello_la_DEPENDENCIES = \
$(top_builddir)/src/util/libgnunetutil.la \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am_libgnunethello_la_OBJECTS = hello.lo address.lo
libgnunethello_la_OBJECTS = $(am_libgnunethello_la_OBJECTS)
-AM_V_lt = $(am__v_lt_$(V))
-am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
libgnunethello_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
@@ -112,26 +136,31 @@ LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
-AM_V_CC = $(am__v_CC_$(V))
-am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
-AM_V_at = $(am__v_at_$(V))
-am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
-AM_V_CCLD = $(am__v_CCLD_$(V))
-am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
-AM_V_GEN = $(am__v_GEN_$(V))
-am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
SOURCES = $(libgnunethello_la_SOURCES) $(gnunet_hello_SOURCES) \
$(test_hello_SOURCES)
DIST_SOURCES = $(libgnunethello_la_SOURCES) $(gnunet_hello_SOURCES) \
$(test_hello_SOURCES)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
ETAGS = etags
CTAGS = ctags
am__tty_colors = \
@@ -172,6 +201,10 @@ EXEEXT = @EXEEXT@
EXT_LIBS = @EXT_LIBS@
EXT_LIB_PATH = @EXT_LIB_PATH@
FGREP = @FGREP@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_GENMARSHAL = @GLIB_GENMARSHAL@
+GLIB_LIBS = @GLIB_LIBS@
+GLIB_MKENUMS = @GLIB_MKENUMS@
GMSGFMT = @GMSGFMT@
GMSGFMT_015 = @GMSGFMT_015@
GNUNETDNS_GROUP = @GNUNETDNS_GROUP@
@@ -182,6 +215,7 @@ GN_LIBINTL = @GN_LIBINTL@
GN_LIB_LDFLAGS = @GN_LIB_LDFLAGS@
GN_PLUGIN_LDFLAGS = @GN_PLUGIN_LDFLAGS@
GN_USER_HOME_DIR = @GN_USER_HOME_DIR@
+GOBJECT_QUERY = @GOBJECT_QUERY@
GREP = @GREP@
HAVE_LIBUNISTRING = @HAVE_LIBUNISTRING@
INCLTDL = @INCLTDL@
@@ -204,6 +238,8 @@ LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@
LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
+LIBGTOP_CFLAGS = @LIBGTOP_CFLAGS@
+LIBGTOP_LIBS = @LIBGTOP_LIBS@
LIBICONV = @LIBICONV@
LIBINTL = @LIBINTL@
LIBLTDL = @LIBLTDL@
@@ -225,6 +261,7 @@ LT_CONFIG_H = @LT_CONFIG_H@
LT_DLLOADERS = @LT_DLLOADERS@
LT_DLPREOPEN = @LT_DLPREOPEN@
MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MONKEYPREFIX = @MONKEYPREFIX@
MSGFMT = @MSGFMT@
@@ -234,6 +271,7 @@ MYSQL_CPPFLAGS = @MYSQL_CPPFLAGS@
MYSQL_LDFLAGS = @MYSQL_LDFLAGS@
NM = @NM@
NMEDIT = @NMEDIT@
+NSS_DIR = @NSS_DIR@
OBJC = @OBJC@
OBJCDEPMODE = @OBJCDEPMODE@
OBJCFLAGS = @OBJCFLAGS@
@@ -249,6 +287,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
POSTGRES_CPPFLAGS = @POSTGRES_CPPFLAGS@
POSTGRES_LDFLAGS = @POSTGRES_LDFLAGS@
POSUB = @POSUB@
@@ -280,6 +319,7 @@ abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
@@ -302,6 +342,7 @@ datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
+gitcommand = @gitcommand@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
@@ -315,7 +356,6 @@ libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
-lt_ECHO = @lt_ECHO@
ltdl_LIBOBJS = @ltdl_LIBOBJS@
ltdl_LTLIBOBJS = @ltdl_LTLIBOBJS@
mandir = @mandir@
@@ -333,6 +373,7 @@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
subdirs = @subdirs@
+svnversioncommand = @svnversioncommand@
sys_symbol_underscore = @sys_symbol_underscore@
sysconfdir = @sysconfdir@
target = @target@
@@ -352,11 +393,12 @@ libgnunethello_la_SOURCES = \
hello.c address.c
libgnunethello_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la $(XLIB)
+ $(top_builddir)/src/util/libgnunetutil.la $(XLIB) \
+ $(LTLIBINTL)
libgnunethello_la_LDFLAGS = \
$(GN_LIB_LDFLAGS) \
- -version-info 0:0:0
+ -version-info 1:0:1
@ENABLE_TEST_RUN_TRUE@TESTS = $(check_PROGRAMS)
test_hello_SOURCES = \
@@ -413,7 +455,6 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps)
$(am__aclocal_m4_deps):
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
- test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
list2=; for p in $$list; do \
if test -f $$p; then \
@@ -421,6 +462,8 @@ install-libLTLIBRARIES: $(lib_LTLIBRARIES)
else :; fi; \
done; \
test -z "$$list2" || { \
+ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
}
@@ -442,7 +485,7 @@ clean-libLTLIBRARIES:
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
-libgnunethello.la: $(libgnunethello_la_OBJECTS) $(libgnunethello_la_DEPENDENCIES)
+libgnunethello.la: $(libgnunethello_la_OBJECTS) $(libgnunethello_la_DEPENDENCIES) $(EXTRA_libgnunethello_la_DEPENDENCIES)
$(AM_V_CCLD)$(libgnunethello_la_LINK) -rpath $(libdir) $(libgnunethello_la_OBJECTS) $(libgnunethello_la_LIBADD) $(LIBS)
clean-checkPROGRAMS:
@@ -462,10 +505,10 @@ clean-noinstPROGRAMS:
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
echo " rm -f" $$list; \
rm -f $$list
-gnunet-hello$(EXEEXT): $(gnunet_hello_OBJECTS) $(gnunet_hello_DEPENDENCIES)
+gnunet-hello$(EXEEXT): $(gnunet_hello_OBJECTS) $(gnunet_hello_DEPENDENCIES) $(EXTRA_gnunet_hello_DEPENDENCIES)
@rm -f gnunet-hello$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(gnunet_hello_OBJECTS) $(gnunet_hello_LDADD) $(LIBS)
-test_hello$(EXEEXT): $(test_hello_OBJECTS) $(test_hello_DEPENDENCIES)
+test_hello$(EXEEXT): $(test_hello_OBJECTS) $(test_hello_DEPENDENCIES) $(EXTRA_test_hello_DEPENDENCIES)
@rm -f test_hello$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(test_hello_OBJECTS) $(test_hello_LDADD) $(LIBS)
@@ -483,26 +526,23 @@ distclean-compile:
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
@@ -643,14 +683,15 @@ check-TESTS: $(TESTS)
fi; \
dashes=`echo "$$dashes" | sed s/./=/g`; \
if test "$$failed" -eq 0; then \
- echo "$$grn$$dashes"; \
+ col="$$grn"; \
else \
- echo "$$red$$dashes"; \
+ col="$$red"; \
fi; \
- echo "$$banner"; \
- test -z "$$skipped" || echo "$$skipped"; \
- test -z "$$report" || echo "$$report"; \
- echo "$$dashes$$std"; \
+ echo "$${col}$$dashes$${std}"; \
+ echo "$${col}$$banner$${std}"; \
+ test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \
+ test -z "$$report" || echo "$${col}$$report$${std}"; \
+ echo "$${col}$$dashes$${std}"; \
test "$$failed" -eq 0; \
else :; fi
@@ -703,10 +744,15 @@ install-am: all-am
installcheck: installcheck-am
install-strip:
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- `test -z '$(STRIP)' || \
- echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
mostlyclean-generic:
clean-generic:
diff --git a/src/hello/address.c b/src/hello/address.c
index 893a6dc..67ad8a0 100644
--- a/src/hello/address.c
+++ b/src/hello/address.c
@@ -113,7 +113,7 @@ GNUNET_HELLO_address_cmp (const struct GNUNET_HELLO_Address *a1,
return -1;
if (a1->address_length > a2->address_length)
return 1;
- return memcmp (a1->address, a1->address, a1->address_length);
+ return memcmp (a1->address, a2->address, a1->address_length);
}
diff --git a/src/hello/gnunet-hello.c b/src/hello/gnunet-hello.c
index bc35cdd..eae16a9 100644
--- a/src/hello/gnunet-hello.c
+++ b/src/hello/gnunet-hello.c
@@ -25,10 +25,6 @@
#include "platform.h"
#include "gnunet_hello_lib.h"
-#define DEBUG GNUNET_EXTRA_LOGGING
-
-#define VERBOSE GNUNET_NO
-
/**
* Closure for 'add_to_buf'.
*/
diff --git a/src/hello/hello.c b/src/hello/hello.c
index 6529c93..becc4da 100644
--- a/src/hello/hello.c
+++ b/src/hello/hello.c
@@ -27,6 +27,7 @@
#include "gnunet_hello_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_util_lib.h"
+#include "gnunet_transport_plugin.h"
GNUNET_NETWORK_STRUCT_BEGIN
@@ -63,6 +64,46 @@ struct GNUNET_HELLO_Message
};
GNUNET_NETWORK_STRUCT_END
+
+/**
+ * Context used for building our own URI.
+ */
+struct GNUNET_HELLO_ComposeUriContext
+{
+ /**
+ * Final URI.
+ */
+ char *uri;
+
+ /**
+ * Function for finding transport plugins by name.
+ */
+ GNUNET_HELLO_TransportPluginsFind plugins_find;
+};
+
+
+/**
+ * Context for 'add_address_to_hello'.
+ */
+struct GNUNET_HELLO_ParseUriContext
+{
+ /**
+ * Position in the URI with the next address to parse.
+ */
+ const char *pos;
+
+ /**
+ * Set to GNUNET_SYSERR to indicate parse errors.
+ */
+ int ret;
+
+ /**
+ * Function for finding transport plugins by name.
+ */
+ GNUNET_HELLO_TransportPluginsFind plugins_find;
+};
+
+
/**
* Copy the given address information into
* the given buffer using the format of HELLOs.
@@ -650,10 +691,10 @@ GNUNET_HELLO_get_last_expiration (const struct GNUNET_HELLO_Message *msg)
*
* The concrete URI format is:
*
- * "gnunet://hello/PEER[!YYYYMMDDHHNNSS!<TYPE>!<ADDRESS>]...".
+ * "gnunet://hello/PEER[!YYYYMMDDHHMMSS!<TYPE>!<ADDRESS>]...".
* These URIs can be used to add a peer record to peerinfo service.
* PEER is the string representation of peer's public key.
- * YYYYMMDDHHNNSS is the expiration date.
+ * YYYYMMDDHHMMSS is the expiration date.
* TYPE is a transport type.
* ADDRESS is the address, its format depends upon the transport type.
* The concrete transport types and corresponding address formats are:
@@ -683,4 +724,316 @@ GNUNET_HELLO_get_last_expiration (const struct GNUNET_HELLO_Message *msg)
* <p>
*/
+
+/* ************************* Compose HELLO URI ************************** */
+
+
+/**
+ * Replace all characters in the input 'in' according
+ * to the mapping. The mapping says to map each character
+ * in 'oldchars' to the corresponding character (by offset)
+ * in 'newchars'.
+ *
+ * @param in input string to remap
+ * @param oldchars characters to replace
+ * @param newchars replacement characters, must have same length as 'oldchars'
+ * @return copy of string with replacement applied.
+ */
+static char *
+map_characters (const char *in,
+ const char *oldchars,
+ const char *newchars)
+{
+ char *ret;
+ const char *off;
+ size_t i;
+
+ GNUNET_assert (strlen (oldchars) == strlen (newchars));
+ ret = GNUNET_strdup (in);
+ i = 0;
+ while (ret[i] != '\0')
+ {
+ off = strchr (oldchars, ret[i]);
+ if (NULL != off)
+ ret[i] = newchars[off - oldchars];
+ i++;
+ }
+ return ret;
+}
+
+
+/**
+ * Function that is called on each address of this peer.
+ * Expands the corresponding URI string.
+ *
+ * @param cls the 'GNUNET_HELLO_GetUriContext'
+ * @param address address to add
+ * @param expiration expiration time for the address
+ * @return GNUNET_OK (continue iteration).
+ */
+static int
+add_address_to_uri (void *cls, const struct GNUNET_HELLO_Address *address,
+ struct GNUNET_TIME_Absolute expiration)
+{
+ struct GNUNET_HELLO_ComposeUriContext *ctx = cls;
+ struct GNUNET_TRANSPORT_PluginFunctions *papi;
+ const char *addr;
+ char *uri_addr;
+ char *ret;
+ char tbuf[16] = "";
+ struct tm *t;
+ time_t seconds;
+
+ papi = ctx->plugins_find (address->transport_name);
+ if (papi == NULL)
+ {
+ /* Not an error - we might just not have the right plugin. */
+ return GNUNET_OK;
+ }
+ if (NULL == papi->address_to_string)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "URI conversion not implemented for plugin `%s'\n",
+ address->transport_name);
+ return GNUNET_OK;
+ }
+ addr = papi->address_to_string (papi->cls, address->address, address->address_length);
+ if ( (addr == NULL) || (strlen(addr) == 0) )
+ return GNUNET_OK;
+ /* For URIs we use '(' and ')' instead of '[' and ']' as brackets are reserved
+ characters in URIs */
+ uri_addr = map_characters (addr, "[]", "()");
+ seconds = expiration.abs_value / 1000;
+ t = gmtime (&seconds);
+
+ GNUNET_asprintf (&ret,
+ "%s!%s!%s!%s",
+ ctx->uri,
+ strftime (tbuf, sizeof (tbuf), "%Y%m%d%H%M%S", t) ? tbuf : "0",
+ address->transport_name,
+ uri_addr);
+ GNUNET_free (uri_addr);
+ GNUNET_free (ctx->uri);
+ ctx->uri = ret;
+ return GNUNET_OK;
+}
+
+
+/**
+ * Compose a hello URI string from a hello message.
+ *
+ * @param hello Hello message
+ * @param plugins_find Function to find transport plugins by name
+ * @return Hello URI string
+ */
+char *
+GNUNET_HELLO_compose_uri (const struct GNUNET_HELLO_Message *hello,
+ GNUNET_HELLO_TransportPluginsFind plugins_find)
+{
+ struct GNUNET_HELLO_ComposeUriContext ctx;
+ ctx.plugins_find = plugins_find;
+
+ char *pkey = GNUNET_CRYPTO_rsa_public_key_to_string (&(hello->publicKey));
+ GNUNET_asprintf (&(ctx.uri),
+ "%s%s",
+ GNUNET_HELLO_URI_PREFIX,
+ pkey);
+ GNUNET_free (pkey);
+
+ GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &add_address_to_uri, &ctx);
+ return ctx.uri;
+}
+
+
+/* ************************* Parse HELLO URI ********************* */
+
+
+/**
+ * We're building a HELLO. Parse the next address from the
+ * parsing context and append it.
+ *
+ * @param cls the 'struct GNUNET_HELLO_AddressParsingContext'
+ * @param max number of bytes available for HELLO construction
+ * @param buffer where to copy the next address (in binary format)
+ * @return number of bytes added to buffer
+ */
+static size_t
+add_address_to_hello (void *cls, size_t max, void *buffer)
+{
+ struct GNUNET_HELLO_ParseUriContext *ctx = cls;
+ const char *tname;
+ const char *address;
+ char *uri_address;
+ char *plugin_address;
+ const char *end;
+ char *plugin_name;
+ struct tm expiration_time;
+ time_t expiration_seconds;
+ struct GNUNET_TIME_Absolute expire;
+ struct GNUNET_TRANSPORT_PluginFunctions *papi;
+ void *addr;
+ size_t addr_len;
+ struct GNUNET_HELLO_Address haddr;
+ size_t ret;
+
+ if (NULL == ctx->pos)
+ return 0;
+ if ('!' != ctx->pos[0])
+ {
+ ctx->ret = GNUNET_SYSERR;
+ GNUNET_break (0);
+ return 0;
+ }
+ ctx->pos++;
+
+ if ('0' == ctx->pos[0] && '!' == ctx->pos[1])
+ {
+ expire = GNUNET_TIME_UNIT_FOREVER_ABS;
+ tname = ctx->pos + 1;
+ }
+ else
+ {
+ memset (&expiration_time, 0, sizeof (expiration_time));
+ tname = strptime (ctx->pos,
+ "%Y%m%d%H%M%S",
+ &expiration_time);
+ if (NULL == tname)
+ {
+ ctx->ret = GNUNET_SYSERR;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Failed to parse HELLO message: missing expiration time\n"));
+ GNUNET_break (0);
+ return 0;
+ }
+
+ expiration_seconds = mktime (&expiration_time);
+ if (expiration_seconds == (time_t) -1)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Failed to parse HELLO message: invalid expiration time\n"));
+ ctx->ret = GNUNET_SYSERR;
+ GNUNET_break (0);
+ return 0;
+ }
+ expire.abs_value = expiration_seconds * 1000;
+ }
+ if ('!' != tname[0])
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Failed to parse HELLO message: malformed\n"));
+ ctx->ret = GNUNET_SYSERR;
+ GNUNET_break (0);
+ return 0;
+ }
+ tname++;
+ address = strchr (tname, (int) '!');
+ if (NULL == address)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Failed to parse HELLO message: missing transport plugin\n"));
+ ctx->ret = GNUNET_SYSERR;
+ GNUNET_break (0);
+ return 0;
+ }
+ address++;
+ end = strchr (address, (int) '!');
+ ctx->pos = end;
+ plugin_name = GNUNET_strndup (tname, address - (tname+1));
+ papi = ctx->plugins_find (plugin_name);
+ if (NULL == papi)
+ {
+ /* Not an error - we might just not have the right plugin.
+ * Skip this part, advance to the next one and recurse.
+ * But only if this is not the end of string.
+ */
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Plugin `%s' not found\n"),
+ plugin_name);
+ GNUNET_free (plugin_name);
+ GNUNET_break (0);
+ return 0;
+ }
+ if (NULL == papi->string_to_address)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Plugin `%s' does not support URIs yet\n"),
+ plugin_name);
+ GNUNET_free (plugin_name);
+ GNUNET_break (0);
+ return 0;
+ }
+ uri_address = GNUNET_strndup (address, end - address);
+ /* For URIs we use '(' and ')' instead of '[' and ']' as brackets are reserved
+ characters in URIs; need to convert back to '[]' for the plugin */
+ plugin_address = map_characters (uri_address, "()", "[]");
+ GNUNET_free (uri_address);
+ if (GNUNET_OK !=
+ papi->string_to_address (papi->cls,
+ plugin_address,
+ strlen (plugin_address) + 1,
+ &addr,
+ &addr_len))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Failed to parse `%s' as an address for plugin `%s'\n"),
+ plugin_address,
+ plugin_name);
+ GNUNET_free (plugin_name);
+ GNUNET_free (plugin_address);
+ return 0;
+ }
+ GNUNET_free (plugin_address);
+ /* address.peer is unset - not used by add_address() */
+ haddr.address_length = addr_len;
+ haddr.address = addr;
+ haddr.transport_name = plugin_name;
+ ret = GNUNET_HELLO_add_address (&haddr, expire, buffer, max);
+ GNUNET_free (addr);
+ GNUNET_free (plugin_name);
+ return ret;
+}
+
+
+/**
+ * Parse a hello URI string to a hello message.
+ *
+ * @param uri URI string to parse
+ * @param pubkey Pointer to struct where public key is parsed
+ * @param hello Pointer to struct where hello message is parsed
+ * @param plugins_find Function to find transport plugins by name
+ * @return GNUNET_OK on success, GNUNET_SYSERR if the URI was invalid, GNUNET_NO on other errors
+ */
+int
+GNUNET_HELLO_parse_uri (const char *uri,
+ struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pubkey,
+ struct GNUNET_HELLO_Message **hello,
+ GNUNET_HELLO_TransportPluginsFind plugins_find)
+{
+ const char *pks;
+ const char *exc;
+ struct GNUNET_HELLO_ParseUriContext ctx;
+
+ if (0 != strncmp (uri,
+ GNUNET_HELLO_URI_PREFIX,
+ strlen (GNUNET_HELLO_URI_PREFIX)))
+ return GNUNET_SYSERR;
+ pks = &uri[strlen (GNUNET_HELLO_URI_PREFIX)];
+ exc = strstr (pks, "!");
+
+ if (GNUNET_OK !=
+ GNUNET_STRINGS_string_to_data (pks,
+ (NULL == exc) ? strlen (pks) : (exc - pks),
+ (unsigned char *) pubkey,
+ sizeof (*pubkey)))
+ return GNUNET_SYSERR;
+
+ ctx.pos = exc;
+ ctx.ret = GNUNET_OK;
+ ctx.plugins_find = plugins_find;
+ *hello = GNUNET_HELLO_create (pubkey, &add_address_to_hello, &ctx);
+
+ return ctx.ret;
+}
+
+
/* end of hello.c */
diff --git a/src/hello/test_hello.c b/src/hello/test_hello.c
index bdabc72..28d4aec 100644
--- a/src/hello/test_hello.c
+++ b/src/hello/test_hello.c
@@ -25,11 +25,6 @@
#include "platform.h"
#include "gnunet_hello_lib.h"
-#define DEBUG GNUNET_NO
-
-#define VERBOSE GNUNET_NO
-
-
static size_t
my_addr_gen (void *cls, size_t max, void *buf)
{
@@ -37,9 +32,8 @@ my_addr_gen (void *cls, size_t max, void *buf)
size_t ret;
struct GNUNET_HELLO_Address address;
-#if DEBUG
- FPRINTF (stderr, "DEBUG: my_addr_gen called with i = %d\n", *i);
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "DEBUG: my_addr_gen called with i = %d\n", *i);
if (0 == *i)
return 0;
memset (&address.peer, 0, sizeof (struct GNUNET_PeerIdentity));
@@ -60,10 +54,9 @@ check_addr (void *cls, const struct GNUNET_HELLO_Address *address,
{
unsigned int *i = cls;
-#if DEBUG
- FPRINTF (stderr, "DEBUG: check_addr called with i = %d and addrlen = %u\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "DEBUG: check_addr called with i = %d and addrlen = %u\n",
*i, (unsigned int) address->address_length);
-#endif
GNUNET_assert (address->address_length > 0);
GNUNET_assert (*i & (1 << (address->address_length - 1)));
*i -= (1 << (address->address_length - 1));
@@ -81,10 +74,9 @@ remove_some (void *cls, const struct GNUNET_HELLO_Address *address,
{
unsigned int *i = cls;
-#if DEBUG
- FPRINTF (stderr, "DEBUG: remove_some called with i = %d and addrlen = %u\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "DEBUG: remove_some called with i = %d and addrlen = %u\n",
*i, (unsigned int) address->address_length);
-#endif
GNUNET_assert (address->address_length > 0);
if (*i & (1 << (address->address_length - 1)))
{
@@ -109,65 +101,56 @@ main (int argc, char *argv[])
GNUNET_log_setup ("test-hello", "DEBUG", NULL);
startup_time = GNUNET_TIME_absolute_get ();
memset (&publicKey, 42, sizeof (publicKey));
-#if VERBOSE
- FPRINTF (stderr, "%s", "Testing HELLO creation (without addresses)...\n");
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing HELLO creation (without addresses)...\n");
i = 0;
msg1 = GNUNET_HELLO_create (&publicKey, &my_addr_gen, &i);
GNUNET_assert (msg1 != NULL);
GNUNET_assert (0 < GNUNET_HELLO_size (msg1));
-#if VERBOSE
- FPRINTF (stderr, "%s", "Testing address iteration (empty set)...\n");
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing address iteration (empty set)...\n");
GNUNET_assert (NULL ==
GNUNET_HELLO_iterate_addresses (msg1, GNUNET_NO, &check_addr,
&i));
-
-#if VERBOSE
- FPRINTF (stderr, "%s", "Testing HELLO creation (with one address)...\n");
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing HELLO creation (with one address)...\n");
i = 1;
msg2 = GNUNET_HELLO_create (&publicKey, &my_addr_gen, &i);
GNUNET_assert (msg2 != NULL);
GNUNET_assert (GNUNET_HELLO_size (msg1) < GNUNET_HELLO_size (msg2));
-#if VERBOSE
- FPRINTF (stderr, "%s", "Testing address iteration (one address)...\n");
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing address iteration (one address)...\n");
i = 1;
GNUNET_assert (NULL ==
GNUNET_HELLO_iterate_addresses (msg2, GNUNET_NO, &check_addr,
&i));
GNUNET_assert (i == 0);
-#if VERBOSE
- FPRINTF (stderr, "%s", "Testing get_key from HELLO...\n");
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing get_key from HELLO...\n");
GNUNET_assert (GNUNET_OK == GNUNET_HELLO_get_key (msg2, &pk));
GNUNET_assert (0 == memcmp (&publicKey, &pk, sizeof (pk)));
GNUNET_free (msg1);
-#if VERBOSE
- FPRINTF (stderr, "%s", "Testing HELLO creation (with two addresses)...\n");
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing HELLO creation (with two addresses)...\n");
i = 2;
msg3 = GNUNET_HELLO_create (&publicKey, &my_addr_gen, &i);
GNUNET_assert (msg3 != NULL);
GNUNET_assert (GNUNET_HELLO_size (msg2) < GNUNET_HELLO_size (msg3));
-#if VERBOSE
- FPRINTF (stderr, "%s", "Testing address iteration (two addresses)...\n");
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing address iteration (two addresses)...\n");
i = 3;
GNUNET_assert (NULL ==
GNUNET_HELLO_iterate_addresses (msg3, GNUNET_NO, &check_addr,
&i));
GNUNET_assert (i == 0);
-#if VERBOSE
- FPRINTF (stderr, "%s", "Testing HELLO merge...\n");
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing HELLO merge...\n");
msg1 = GNUNET_HELLO_merge (msg2, msg3);
GNUNET_assert (GNUNET_HELLO_size (msg1) == GNUNET_HELLO_size (msg3));
@@ -178,9 +161,8 @@ main (int argc, char *argv[])
GNUNET_assert (i == 0);
GNUNET_free (msg1);
-#if VERBOSE
- FPRINTF (stderr, "%s", "Testing address iteration to copy HELLO...\n");
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing address iteration to copy HELLO...\n");
i = 2;
msg1 = GNUNET_HELLO_iterate_addresses (msg3, GNUNET_YES, &remove_some, &i);
GNUNET_assert (msg1 != NULL);
@@ -192,9 +174,8 @@ main (int argc, char *argv[])
GNUNET_assert (i == 0);
GNUNET_free (msg1);
-#if VERBOSE
- FPRINTF (stderr, "%s", "Testing delta address iteration...\n");
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing delta address iteration...\n");
i = 2;
GNUNET_HELLO_iterate_new_addresses (msg3, msg2, startup_time, &check_addr,
&i);