[hipl-dev] [Branch ~rene-hummen/hipl/ipsec_esp] Rev 4940: merged to lp:hipl revision 5140

  • From: noreply@xxxxxxxxxxxxx
  • To: HIPL core team <hipl-dev@xxxxxxxxxxxxx>
  • Date: Tue, 09 Nov 2010 16:41:01 -0000

Merge authors:
  Andrius Bentkus <andrius.bentkus@xxxxxxxxxxxxxx>
  Andrius.Bentkus@xxxxxxxxxxxxxx
  Artturi Karila (artturi-karila)
  Christof Mroz (christof-mroz)
  Christoph Viethen (cviethen)...

------------------------------------------------------------
revno: 4940 [merge]
committer: Rene Hummen <rene.hummen@xxxxxxxxxxxxxxxxx>
branch nick: ipsec_esp
timestamp: Tue 2010-11-09 17:37:54 +0100
message:
  merged to lp:hipl revision 5140
removed:
  tools/bzrhooks/
  tools/bzrhooks/email/
  tools/bzrhooks/email/README
  tools/bzrhooks/email/__init__.py
  tools/bzrhooks/email/customlogformatter.py
  tools/bzrhooks/email/emailer.py
  tools/bzrhooks/email/setup.py
  tools/bzrhooks/email/tests/
  tools/bzrhooks/email/tests/__init__.py
  tools/bzrhooks/email/tests/test_smtp_connection.py
  tools/bzrhooks/email/tests/testemail.py
  tools/bzrhooks/syntaxchecker/
  tools/bzrhooks/syntaxchecker/__init__.py
  tools/bzrhooks/syntaxchecker/syntaxchecker.py
  tools/bzrhooks/tagchecker/
  tools/bzrhooks/tagchecker/__init__.py
  tools/bzrhooks/tagchecker/tagchecker.py
  tools/mailer.sh
added:
  test/check_lib_core.c
  test/lib/
  test/lib/core/
  test/lib/core/hit.c
  test/lib/core/straddr.c
renamed:
  doc/HOWTO.xml => doc/HOWTO.xml.in
  tools/hipdnsproxy/hipdnsproxy => tools/hipdnsproxy/hipdnsproxy.in
  tools/nsupdate.pl => tools/nsupdate.pl.in
modified:
  .bzrignore
  INSTALL
  Makefile.am
  configure.ac
  debian/control
  debian/rules
  doc/Doxyfile.in
  doc/HACKING
  doc/doxygen.h
  firewall/cache.c
  firewall/cache.h
  firewall/cache_port.c
  firewall/cache_port.h
  firewall/common_types.h
  firewall/conntrack.c
  firewall/conntrack.h
  firewall/dlist.c
  firewall/dlist.h
  firewall/esp_prot_api.c
  firewall/esp_prot_api.h
  firewall/esp_prot_config.c
  firewall/esp_prot_config.h
  firewall/esp_prot_conntrack.c
  firewall/esp_prot_conntrack.h
  firewall/esp_prot_defines.h
  firewall/esp_prot_fw_msg.c
  firewall/esp_prot_fw_msg.h
  firewall/firewall.c
  firewall/firewall.h
  firewall/firewall_control.c
  firewall/firewall_control.h
  firewall/firewall_defines.h
  firewall/helpers.c
  firewall/helpers.h
  firewall/hslist.c
  firewall/hslist.h
  firewall/lsi.c
  firewall/lsi.h
  firewall/midauth.c
  firewall/midauth.h
  firewall/pisa.c
  firewall/pisa.h
  firewall/pisa_cert.c
  firewall/pisa_cert.h
  firewall/reinject.c
  firewall/reinject.h
  firewall/rule_management.c
  firewall/rule_management.h
  firewall/sysopp.c
  firewall/sysopp.h
  firewall/user_ipsec_api.c
  firewall/user_ipsec_api.h
  firewall/user_ipsec_esp.c
  firewall/user_ipsec_esp.h
  firewall/user_ipsec_fw_msg.c
  firewall/user_ipsec_fw_msg.h
  firewall/user_ipsec_sadb.c
  firewall/user_ipsec_sadb.h
  hipd/accessor.c
  hipd/accessor.h
  hipd/cert.c
  hipd/cert.h
  hipd/close.c
  hipd/close.h
  hipd/configfilereader.c
  hipd/configfilereader.h
  hipd/cookie.c
  hipd/cookie.h
  hipd/dh.c
  hipd/dh.h
  hipd/hadb.c
  hipd/hadb.h
  hipd/hadb_legacy.c
  hipd/hadb_legacy.h
  hipd/hidb.c
  hipd/hidb.h
  hipd/hip_socket.c
  hipd/hip_socket.h
  hipd/hipd.c
  hipd/hipd.h
  hipd/hiprelay.c
  hipd/hiprelay.h
  hipd/hit_to_ip.c
  hipd/hit_to_ip.h
  hipd/init.c
  hipd/init.h
  hipd/input.c
  hipd/input.h
  hipd/keymat.c
  hipd/keymat.h
  hipd/maintenance.c
  hipd/maintenance.h
  hipd/nat.c
  hipd/nat.h
  hipd/netdev.c
  hipd/netdev.h
  hipd/nsupdate.c
  hipd/nsupdate.h
  hipd/oppdb.c
  hipd/oppdb.h
  hipd/oppipdb.c
  hipd/oppipdb.h
  hipd/output.c
  hipd/output.h
  hipd/pisa.c
  hipd/pisa.h
  hipd/pkt_handling.c
  hipd/pkt_handling.h
  hipd/registration.c
  hipd/registration.h
  hipd/user.c
  hipd/user.h
  lib/core/builder.c
  lib/core/builder.h
  lib/core/capability.c
  lib/core/capability.h
  lib/core/certtools.c
  lib/core/certtools.h
  lib/core/common.h
  lib/core/conf.c
  lib/core/conf.h
  lib/core/crypto.c
  lib/core/crypto.h
  lib/core/debug.c
  lib/core/debug.h
  lib/core/filemanip.c
  lib/core/filemanip.h
  lib/core/hashchain.c
  lib/core/hashchain.h
  lib/core/hashchain_store.c
  lib/core/hashchain_store.h
  lib/core/hashtable.c
  lib/core/hashtable.h
  lib/core/hashtree.c
  lib/core/hashtree.h
  lib/core/hip_udp.c
  lib/core/hip_udp.h
  lib/core/hit.c
  lib/core/hit.h
  lib/core/hostid.c
  lib/core/hostid.h
  lib/core/hostsfiles.c
  lib/core/hostsfiles.h
  lib/core/icomm.h
  lib/core/ife.h
  lib/core/keylen.c
  lib/core/keylen.h
  lib/core/linkedlist.c
  lib/core/linkedlist.h
  lib/core/list.h
  lib/core/message.c
  lib/core/message.h
  lib/core/performance.c
  lib/core/performance.h
  lib/core/prefix.c
  lib/core/prefix.h
  lib/core/protodefs.h
  lib/core/solve.c
  lib/core/solve.h
  lib/core/state.h
  lib/core/statistics.c
  lib/core/statistics.h
  lib/core/straddr.c
  lib/core/straddr.h
  lib/core/transform.c
  lib/core/transform.h
  lib/core/util.h
  lib/modularization/lmod.c
  lib/modularization/lmod.h
  lib/tool/lutil.c
  lib/tool/lutil.h
  lib/tool/nlink.c
  lib/tool/nlink.h
  lib/tool/xfrmapi.c
  lib/tool/xfrmapi.h
  modules/esp_tokens/hipd/esp_prot_anchordb.c
  modules/esp_tokens/hipd/esp_prot_anchordb.h
  modules/esp_tokens/hipd/esp_prot_hipd_msg.c
  modules/esp_tokens/hipd/esp_prot_hipd_msg.h
  modules/esp_tokens/hipd/esp_prot_light_update.c
  modules/esp_tokens/hipd/esp_prot_light_update.h
  modules/esp_tokens/lib/esp_prot_common.c
  modules/esp_tokens/lib/esp_prot_common.h
  modules/heartbeat/hipd/heartbeat.c
  modules/heartbeat/hipd/heartbeat.h
  modules/heartbeat_update/hipd/hb_update.c
  modules/heartbeat_update/hipd/hb_update.h
  modules/update/hipd/update.c
  modules/update/hipd/update.h
  modules/update/hipd/update_legacy.c
  modules/update/hipd/update_legacy.h
  modules/user_ipsec/hipd/user_ipsec_hipd_msg.c
  modules/user_ipsec/hipd/user_ipsec_hipd_msg.h
  modules/user_ipsec/hipd/user_ipsec_sadb_api.c
  modules/user_ipsec/hipd/user_ipsec_sadb_api.h
  packaging/create-package.sh
  packaging/debbuild
  packaging/hipl-deb.spec
  packaging/hipl-rpm.spec
  packaging/openwrt/package/Makefile
  test/auth_performance.c
  test/certteststub.c
  test/dh_performance.c
  test/hc_performance.c
  tools/hipconf.c
  tools/hipdnsproxy/hosts.py
  tools/hipl_autobuild.sh
  tools/maintainer/sync-all
  tools/maintainer/update-html-code
  tools/pisacert.c
  doc/HOWTO.xml.in
  tools/hipdnsproxy/hipdnsproxy.in
  tools/nsupdate.pl.in


--
lp:~rene-hummen/hipl/ipsec_esp
https://code.launchpad.net/~rene-hummen/hipl/ipsec_esp

Your team HIPL core team is subscribed to branch lp:~rene-hummen/hipl/ipsec_esp.
To unsubscribe from this branch go to 
https://code.launchpad.net/~rene-hummen/hipl/ipsec_esp/+edit-subscription
=== modified file '.bzrignore'
--- .bzrignore  2010-07-07 09:15:40 +0000
+++ .bzrignore  2010-10-29 12:51:08 +0000
@@ -31,6 +31,7 @@
 doc/Doxyfile
 doc/HOWTO.html
 doc/HOWTO.txt
+doc/HOWTO.xml
 doc/doxy/
 firewall/hipfw
 hipd/hipd
@@ -41,6 +42,7 @@
 m4/*.m4
 missing
 py-compile
+rpmbuild/
 stamp-h1
 tags
 test/auth_performance
@@ -49,7 +51,8 @@
 test/hc_performance
 tools/hipconf
 tools/hipdnskeyparse
-tools/hipdnsproxy
+tools/hipdnsproxy/hipdnsproxy
+tools/nsupdate.pl
 tools/pisacert
 modules/hipd_modules.h
 version.h

=== modified file 'INSTALL'
--- INSTALL     2010-08-25 16:46:44 +0000
+++ INSTALL     2010-10-29 11:30:05 +0000
@@ -27,7 +27,10 @@
 Make and gcc. openssl, iptables, libcap and libconfig are required complete
 with development headers. For Perl, Socket6, IO::Socket::INET6, Net::IP and
 Net::DNS modules are required. You can optionally install xmlto to
-build the HOWTO and doxygen to build the code documentation.
+build the HOWTO and doxygen to build the code documentation. Installing the
+optional check library (http://check.sourceforge.net/) enables unit tests.
+Some additional libraries are needed for building binary packages (fakeroot
+and dpkg-dev on ubuntu).
 
 On Ubuntu, the following command(s) should solve the dependencies:
 
@@ -35,7 +38,8 @@
     iptables-dev libcap-dev libnet-ip-perl libnet-dns-perl \
     libsocket6-perl libio-socket-inet6-perl
 
-  Optionally: aptitude install pax miredo bzr xmlto doxygen
+  Optionally: aptitude install pax miredo bzr xmlto doxygen check fakeroot
+                         dpkg-dev
 
 On Fedora, the following command(s) should solve the dependencies:
 
@@ -73,3 +77,14 @@
   CFLAGS=-Wno-error ./configure
 
 Then run make as usual.
+
+
+Broken Systems
+==============
+
+HIPL is known not to compile out-of-the-box on some platforms. In cases where
+the platform is clearly at fault we try not to clutter our sources with
+workarounds, but rely on the user to pass flags to configure. Below is
+a list of known-broken systems along with workarounds.
+
+CentOS 5.5: CPPFLAGS=-U__STRICT_ANSI__ ./configure

=== modified file 'Makefile.am'
--- Makefile.am 2010-09-03 11:40:19 +0000
+++ Makefile.am 2010-11-09 16:37:54 +0000
@@ -38,6 +38,16 @@
 lib_LTLIBRARIES += lib/modularization/libmod.la
 
 
+### tests ###
+TESTS           =
+check_PROGRAMS  =
+
+if HIP_UNITTESTS
+TESTS           += check_lib_core
+check_PROGRAMS  += check_lib_core
+endif
+
+
 ### source declarations ###
 
 test_auth_performance_SOURCES = test/auth_performance.c
@@ -110,8 +120,6 @@
 endif
 
 
-# TODO: libhipcore, libhipconf and libhiptool have circular
-# dependencies. This needs to be addressed at some point.
 lib_core_libhipcore_la_SOURCES = lib/core/builder.c         \
                                  lib/core/capability.c      \
                                  lib/core/certtools.c       \
@@ -147,6 +155,10 @@
 
 lib_modularization_libmod_la_SOURCES = lib/modularization/lmod.c
 
+check_lib_core_SOURCES =    test/check_lib_core.c          \
+                            test/lib/core/hit.c            \
+                            test/lib/core/straddr.c
+
 # Initialize LDADD lists empty, because modules might add entries to LDADD. The
 # module LDADDs need to be included before the standard LDADDs, because modules
 # can depend on the core code.
@@ -164,6 +176,7 @@
 
 ### library dependencies ###
 
+check_lib_core_LDADD           = lib/core/libhipcore.la
 firewall_hipfw_LDADD          += lib/core/libhipcore.la
 hipd_hipd_LDADD               += lib/modularization/libmod.la \
                                  lib/core/libhipcore.la
@@ -221,10 +234,10 @@
 
 CLEANFILES = doc/HOWTO.html doc/HOWTO.txt
 clean-local:
-       rm -rf doc/doxy
+       rm -rf doc/doxy debbuild rpmbuild
 
-bin deb increl rpm syncrepo:
-       env PYEXECDIR=$(pyexecdir) @srcdir@/packaging/create-package.sh $@
+bin deb rpm syncrepo syncrepo_deb syncrepo_rpm: $(srcdir)/version.h
+       @srcdir@/packaging/create-package.sh $@
 
 autotools-clean: maintainer-clean
        rm -f aclocal.m4 compile config.* configure depcomp install-sh
@@ -242,7 +255,7 @@
 # Ensure that version.h is created before everything else. This does not work
 # when creating specific objects that may depend on version.h directly.
 BUILT_SOURCES = version.h
-$(srcdir)/version.h: $(wildcard $(srcdir)/.bzr/branch/last-revision)
+$(srcdir)/version.h: $(wildcard $(srcdir)/.bzr/checkout/dirstate)
        bzr version-info $(srcdir) --custom --template='#define BZR_REVISION 
"{revno}"\n#define BZR_DATE "{date}"\n#define BZR_BRANCH "{branch_nick}"\n' > $@
 
 
@@ -251,4 +264,4 @@
 dist-hook:
        rm -f $(distdir)/doc/Doxyfile
 
-.PHONY: bin checkheaders deb doxygen increl rpm syncrepo
+.PHONY: bin checkheaders deb doxygen rpm syncrepo*

=== modified file 'configure.ac'
--- configure.ac        2010-08-19 09:40:48 +0000
+++ configure.ac        2010-10-29 12:51:08 +0000
@@ -39,6 +39,10 @@
               AH_TEMPLATE(HAVE_EC_CRYPTO, [Defined to 1 if ec is enabled.]),)
 # We need the math lib in the registration extension.
 AC_CHECK_LIB(m, pow,, AC_MSG_ERROR(Math lib not found))
+# The unit tests depend on 'check' (http://check.sourceforge.net/)
+AC_CHECK_LIB(check, suite_create,,
+             AC_MSG_WARN(libcheck (http://check.sourceforge.net/) not found: 
HIPL unit tests are not available),)
+AM_CONDITIONAL(HIP_UNITTESTS, test x"$ac_cv_lib_check_suite_create" = xyes)
 
 # If no --prefix option is passed to configure, $prefix is empty. But we want
 # to expand $sysconfdir, which defaults to ${prefix}/etc. So set $prefix.
@@ -49,9 +53,12 @@
 AC_DEFINE_UNQUOTED(HIPL_DEFAULT_PREFIX, "$(eval echo ${prefix})")
 AH_TEMPLATE(HIPL_DEFAULT_PREFIX, [default prefix])
 
+# Our configuration files should be located in a subdirectory of their own.
+# The variable is evaluated and echoed to produce a string that can be
+# substituted for references to configuration files throughout the codebase.
+AC_SUBST(sysconfdir, $(eval echo ${sysconfdir}/hip))
+
 # Default sysconf and lockfile directory
-# TODO: @Miika is there any better way to define this?
-AC_SUBST(sysconfdir, /etc/hip/)
 AC_DEFINE_UNQUOTED(HIPL_SYSCONFDIR, "$(eval echo $sysconfdir)")
 AH_TEMPLATE(HIPL_SYSCONFDIR, [default configuration file location])
 
@@ -59,10 +66,10 @@
 AC_DEFINE_UNQUOTED(HIPL_LOCKDIR, "$(eval echo $lockdir)")
 AH_TEMPLATE(HIPL_LOCKDIR, [default lock file location])
 
-AC_DEFINE_UNQUOTED(HIPL_HOSTS_FILE, "$(eval echo ${sysconfdir}hosts)")
+AC_DEFINE_UNQUOTED(HIPL_HOSTS_FILE, "$(eval echo ${sysconfdir}/hosts)")
 AH_TEMPLATE(HIPL_HOSTS_FILE, [default hosts file location])
 
-AC_DEFINE_UNQUOTED(HIPL_CONFIG_FILE, "$(eval echo ${sysconfdir}hipd_config)")
+AC_DEFINE_UNQUOTED(HIPL_CONFIG_FILE, "$(eval echo ${sysconfdir}/hipd_config)")
 AH_TEMPLATE(HIPL_CONFIG_FILE, [default config file location])
 
 
@@ -214,6 +221,6 @@
 echo "+-----------------------------------------------"
 echo ""
 
-AC_CONFIG_FILES([ Makefile doc/Doxyfile ])
+AC_CONFIG_FILES([ Makefile doc/Doxyfile doc/HOWTO.xml tools/nsupdate.pl 
tools/hipdnsproxy/hipdnsproxy ])
 
 AC_OUTPUT

=== modified file 'debian/control'
--- debian/control      2010-03-08 16:42:31 +0000
+++ debian/control      2010-10-01 18:00:52 +0000
@@ -1,4 +1,6 @@
 Source: hipl
+Section: net
+Priority: optional
 Maintainer: Rene Hummen <rene.hummen@xxxxxxxxxxxxxxxxx>
 Build-Depends: debhelper (>= 5), autotools-dev
 Standards-Version: 3.7.2

=== modified file 'debian/rules'
--- debian/rules        2010-05-28 11:25:28 +0000
+++ debian/rules        2010-10-01 16:44:09 +0000
@@ -33,7 +33,6 @@
 endif
        ./configure $(CROSS) --prefix=/usr --sysconfdir=/etc \
                          --enable-shared \
-                         --disable-gcc-warn \
                          --disable-debug
 
 

=== modified file 'doc/Doxyfile.in'
--- doc/Doxyfile.in     2010-05-31 09:44:40 +0000
+++ doc/Doxyfile.in     2010-09-27 15:58:51 +0000
@@ -1024,7 +1024,7 @@
 # compilation will be performed. Macro expansion can be done in a controlled
 # way by setting EXPAND_ONLY_PREDEF to YES.
 
-MACRO_EXPANSION        = NO
+MACRO_EXPANSION        = YES
 
 # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
 # then the macro expansion is limited to the macros specified with the
@@ -1058,7 +1058,7 @@
 # undefined via #undef or recursively expanded use the := operator
 # instead of the = operator.
 
-PREDEFINED             =
+PREDEFINED             = STACK_OF
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
 # this tag can be used to specify a list of macro names that should be 
expanded.

=== modified file 'doc/HACKING'
--- doc/HACKING 2010-08-29 11:26:22 +0000
+++ doc/HACKING 2010-11-09 09:07:47 +0000
@@ -137,6 +137,9 @@
 changes and to use the extra information for eventual bugfixes in the
 future.
 
+NOTE: To automatically close a bug in launchpad, use
+bzr commit --fixes lp:#BUG_ID#
+
 NOTE: You can set your preferred editor by editing the [DEFAULT]
 section of Bazaar configuration located at $HOME/.bazaar/bazaar.conf,
 e.g.:
@@ -488,9 +491,9 @@
 ------------------------
 
 - line length:
-  Long lines (>80 characters) should be broken at suitable places
-  where doing so improves readability. Broken lines should not be
-  mechanically indented by four spaces. Instead they should be
+  Long lines (>80 characters) should be broken at suitable places if
+  and only if doing so improves readability. Broken lines should not
+  be mechanically indented by four spaces. Instead they should be
   indented for optimum readability. For example function arguments
   placed on the next line should align with the first character
   after the '('.
@@ -512,8 +515,9 @@
 parentheses:
 
 
-#include <stddef.h>     /* Use <> for system #includes. */
-#include "header.h"     /* Use "" for local #includes. */
+#include <stddef.h>     // System #includes come first, use <> and
+                        // are separated by an empty line from
+#include "header.h"     // local #includes, which use "".
 
 struct whatever {
     /* Observe how the variable names and the stars are aligned. */
@@ -680,14 +684,132 @@
 
 Modify the numbers depending on your hardware to suit your needs.
 
+UNIT TESTS
+==========
+You can (and are recommended to) use unit testing to improve code quality.
+
+The command
+
+#> make check
+
+runs the existing unit tests.
+HIPL uses the check framework (http://check.sourceforge.net/) for unit tests.
+It is available in source and binary form, e.g. the Debian package 'check'.
+
+What To Test?
+-------------
+Unit tests check whether implementations conform to their specification (i.e.,
+their documentation). Some rules of thumb for writing tests are:
+
+- test the documented aspects of a function: does it behave as expected? does
+  it catch invalid input as documented?
+
+- test undocumented aspects of a function: how does it handle invalid input
+  (e.g., NULL pointers, empty strings, negative integers) that the compiler
+  cannot catch?
+
+Test coverage: At the very least, tests should ensure that a function can
+handle valid and invalid input as documented. Ideally, they also test corner
+cases and unusual input and state. Obviously, unit tests are limited
+in testing whether a function fully behaves as documented because that can be
+very complex, slow, or impossible on a local system.
+
+Unit Tests Organizition
+-----------------------
+The unit tests are organized as follows:
+
+- all test code resides in the test directory. The directories below test
+  mirror those in the main hipl directory to organize the tests in the same
+  layout.
+
+- test programs: There is one test program per hipl component. At the time of
+  this writing, the only test program is check_lib_core for all tests that
+  relate to the files from lib/core. By convention, each test program is
+  called check_<component name> where <component name> is the name of the
+  directory that contains the component. Test programs are defined in
+  Makefile.am.
+
+- test suites: Each test program consists of several test suites, one for each
+  implementation file to test. By convention, the tests of the test suite for
+  lib/core/hit.c are contained in test/lib/core/hit.c, which exports them as a
+  suite to the check_lib_core test program.
+
+- tests: Each test suite consists of one or more tests that test a specific
+  aspect of a function from the implementation. For example, the test function
+  test_hip_convert_hit_to_str_valid() in test/lib/core/hit.c tests whether the
+  function hip_convert_hit_to_str() from lib/core/hit.c works as expected with
+  valid input parameters. By convention, the test function is called
+  test_<function under test>_<test aspect>().
+
+Adding Unit Tests
+-----------------
+To add a unit test for the function foo() in the file hipd/bar.c, follow these
+steps:
+
+* If it does not exist, create a test program for the hipd component:
+  - copy an existing test program implementation (test/check_*.c) to
+    test/check_hipd.c
+  - remove the existing "extern Suite" and "srunner_add_suite()" statements
+  - in Makefile.am:
+    * add the check_hipd test program to TESTS
+    * add the check_hipd test program to check_PROGRAMS
+    * add the file test/check_hipd.c to check_hipd_SOURCES
+    * add the check library from the check framework and all libraries your
+      test program depends on (usually the same as the original component
+      hipd) to check_hipd_LDADD
+  - create the directory test/hipd for your test suites
+  - re-run the automake tool chain
+* If it does not exist, create the test suite for the file hipd/bar.c:
+  - copy an existing test suite (test/hipd/*.c) to test/hipd/bar.c.
+  - in test/hipd/bar.c, make sure you include the test target's header file
+    (#include "hipd/bar.h" in this example)
+  - in test/hipd/bar.c, remove all tests and tcase_add_test() statements
+  - in test/hipd/bar.c, adapt the name of the test suite in the invocation of
+    suite_create() to "hipd/bar"
+  - add test/hipd/bar.c to check_hipd_SOURCES in Makefile.am
+  - re-run the automake tool chain
+* Create the test case:
+  - implement the test function called test_foo_<test aspect>() in
+    test/hipd/bar.c (see other test suites and the check documentation for
+    details)
+  - register the test function to the test suite by adding a corresponding
+    tcase_add_test() function call to hipd_bar() in test/hipd/bar.c.
+    If you'd like to test for an HIP_ASSERT() to occur, use
+    tcase_add_exit_test().
+  - run "make check"
+
+Testing Static Functions
+------------------------
+Usually, unit tests are not intended to apply to static functions and doing so
+is difficult because these functions are not accessible by test programs
+from outside of the files that define them. However, static functions
+are commonplace in HIPL and often form relevant test targets. Developers are
+thus encouraged to apply unit tests to static functions as well as to
+non-static functions with external visibility.
+
+There are two approaches to making static functions visible within the test
+programs (adopting the names from the organization example above):
+
+a) Instead of including hipd/bar.h, include the implementation file hipd/bar.c
+   directly. While not an elegant solution, it is the simplest approach that
+   should work in most cases.
+
+b) For the test target static foo() create the wrapper foo_test_wrapper() that
+   is not static. Declare all such wrappers in hipd/bar_test_wrappers.h and
+   include that file instead of hipd/bar.h. While more effort, this is cleaner
+   than solution a) and should work where a) prooves problematic.
+
+
 DEBUGGING
 =========
 
-Debugging the kernel with gdb is not possible unless you're running
-User Mode Linux and in such cases you may prefer manual debugging
-statements in the code. It may be also your personal favourite to
-prefer debugging statements over gdb in the userspace. HIPL provides a
-set of wrappers for adding debugging statements in a concise way:
+You can debug HIPL code using gdb. The recommended way to configure a
+debug build is as follows:
+
+./configure <options> CFLAGS='-g -O0'
+
+Alternatively, HIPL provides a set of wrappers for printing or logging
+debugging statements in a unified way:
 
 - HIP_DIE(arguments as for printk)
 - HIP_ERROR(arguments as for printk)
@@ -797,10 +919,12 @@
 The special commands comment the function parameters and the return value.
 Furthermore an extra note is added to this comment with "@note" and a reference
 to a related function with "@see". Notice how we refer to the function
-parameters in the description text with the special command "@c" Including this
+parameters in the description text with the special command "@a" Including this
 special command is by no way obligatory. It only makes the next word to be
-rendered using Courier instead of the default font. However, be careful not to
-add your own special commands by accidentally typing something like @entry.
+rendered using Courier instead of the default font. If that causes a
+doxygen warning, try "@c" which results in courier too, but doesn't confer
+semantics like "@a". However, be careful not to add your own special commands
+by accidentally typing something like @entry.
 
 Function comment blocks must be placed to the c-source file.  Doxygen
 comment blocks have a tendency to bloat the code. Generally, if
@@ -808,6 +932,23 @@
 c-file.  This applies to all Doxygen comments, not just function
 comments.
 
+To ensure correct cross-referencing, global variables should be prepended
+by :: and functions appended by () in comment blocks, like this:
+
+/**
+ * Stores information about one ESP connection endpoint (i.e., one SPI).
+ *
+ * @todo Write allocator/deallocator for automatic synching with ::espList.
+ */
+struct esp_tuple { /* ... */ };
+
+/**
+ * A connection (i.e., two tuples).
+ * alloc/dealloc using insert_new_connection() or
+ * remove_connection(), respectively.
+ */
+struct connection { /*...*/  };
+
 Doxygen includes a special tag for todo items. The todo tag is "@todo". The 
todo
 tag can be placed anywhere in the code. When placed inside of a function, the
 todo item becomes a todo item for the respective function. When placed outside
@@ -827,7 +968,8 @@
 Example 6. From example 6 we notice that Doxygen comments can also include
 simple HTML.
 
-/**@file
+/**
+ * @file
  * This file defines various functions for handling HIP messages.
  *
  * @author  John Doe
@@ -851,7 +993,7 @@
 following comment block in doc/doxygen.h, example 7.
 
 /**
- * @file lib/core/protodefs.h
+ * @file
  * @def  HIP_NTF_INVALID_SYNTAX
  *       Indicates that the HIP message received was invalid because...
  */
@@ -991,10 +1133,6 @@
 Install repository tool at the host where you are building packages:
 * yum -y install createrepo
 
-Remember update version number in hipl.spec before
-uploading any binaries!!!
-* make increl
-
 Create binaries and synchronise to repository:
 * make bin syncrepo
 
@@ -1019,10 +1157,6 @@
 Install the following tool to the host where building packages:
 * apt-get install dpkg-scanpackages
 
-Note: if you are doing a version upgrade, remember to update the
-version number in hipl-deb.spec!!!
-* make increl
-
 Build the binaries and synchronize to repository:
 * make bin syncrepo
 

=== renamed file 'doc/HOWTO.xml' => 'doc/HOWTO.xml.in'
--- doc/HOWTO.xml       2010-08-31 09:27:03 +0000
+++ doc/HOWTO.xml.in    2010-10-29 12:51:08 +0000
@@ -684,7 +684,7 @@
           </para>
           <para>
   <programlisting>
-  $ make package/hipl-install V=99
+  $ make package/hipl/install V=99
   </programlisting>
           </para>
         </listitem>
@@ -831,7 +831,7 @@
           </para>
           <para>
 <programlisting>
-$ make package/hipl-install V=99
+$ make package/hipl/install V=99
 </programlisting>
           </para>
         </listitem>
@@ -1130,7 +1130,7 @@
           </para>
           <para>
   <programlisting>
-  $ make package/hipl-install V=99
+  $ make package/hipl/install V=99
   </programlisting>
           </para>
         </listitem>
@@ -1540,17 +1540,17 @@
     </para>
 
     <itemizedlist>
-      <listitem><programlisting>Version of HIPL software. Ubuntu: dpkg -l 
'hipl*'. Redhat-based distros: rpm -qa|grep hipl</programlisting></listitem>
+      <listitem><programlisting>Version of HIPL software. Ubuntu: dpkg -l 
'hipl*'. Redhat-based distros: rpm -qa | grep hipl</programlisting></listitem>
       <listitem><programlisting>hipconf get ha all</programlisting></listitem>
       <listitem><programlisting>ip xfrm state</programlisting></listitem>
       <listitem><programlisting>uname -a</programlisting></listitem>
       <listitem><programlisting>lsb_release -a</programlisting></listitem>
-      <listitem><programlisting>cat 
/etc/hip/hipd_config</programlisting></listitem>
+      <listitem><programlisting>cat 
@sysconfdir@/hipd_config</programlisting></listitem>
       <listitem><programlisting>cat 
/etc/selinux/config</programlisting></listitem>
       <listitem><programlisting>iptables -L -n</programlisting></listitem>
       <listitem><programlisting>ip6tables -L -n</programlisting></listitem>
-      <listitem><programlisting>ps axu|grep hip</programlisting></listitem>
-      <listitem><programlisting>ps axu|grep dns</programlisting></listitem>
+      <listitem><programlisting>ps axu | grep hip</programlisting></listitem>
+      <listitem><programlisting>ps axu | grep dns</programlisting></listitem>
     </itemizedlist>
 
    <!--
@@ -1706,7 +1706,7 @@
       This will setup a HIP connection between the two hosts (it may take a
       while if you are using virtual machines). You should replace
       HIT_OF_XXX with the HIT of the host XXX. The hip daemon loads (and
-      creates if necessary) the host identities from /etc/hip automatically.
+      creates if necessary) the host identities from @sysconfdir@ 
automatically.
       If you want to know the default HIT of the localhost, run
       "hipconf get hi default".
       You can list all HITs of the machine with "hipconf get hi all". By
@@ -1723,7 +1723,7 @@
       hipconf add map PEER_HIT PEER_IP
     </para>
     <para>
-      You can also add the mapping to "/etc/hip/hipd_config" and restart hipd.
+      You can also add the mapping to "@sysconfdir@/hipd_config" and restart 
hipd.
       It is also possible to use DNS for the mappings.
     </para>
     <para>
@@ -1788,7 +1788,7 @@
               HIP_DEBUG&gt;
             </para>
             <para>
-              These options can be also set in "/etc/hip/hipd_config" to 
configure
+              These options can be also set in "@sysconfdir@/hipd_config" to 
configure
               hipd and other libraries at startup.
             </para>
             <para>
@@ -1849,7 +1849,7 @@
               </para></listitem>
             </itemizedlist>
             <para>
-              Beforehand the following rules must be added in the file 
/etc/hip/firewall.conf
+              Beforehand the following rules must be added in the file 
@sysconfdir@/firewall.conf
             </para>
             <para>crash:</para>
               <itemizedlist>
@@ -1994,14 +1994,14 @@
       <para>
         3a. If you want to maintain separate files for HIP identifiers,
         write the HIT-hostname (or LSI-hostname)
-        pair to /etc/hip/hosts and the IP-hostname pair to /etc/hosts.
+        pair to @sysconfdir@/hosts and the IP-hostname pair to /etc/hosts.
         See also the method (2) for overloading all addresses in
         /etc/hosts.
       </para>
       <para>
         3b. Execute "hipconf add map PEER_HIT PEER_IP" and use the HIT directly
         in the application. You can insert the
-        hipconf command also to /etc/hip/hipd_config and restart hipd.
+        hipconf command also to @sysconfdir@/hipd_config and restart hipd.
       </para>
     </section>
     <section id="sec_advanced_methods">
@@ -2338,7 +2338,7 @@
     <para>As NFSv3 supports only IPv4, you need use LSIs. So, make sure that
           you are running also hipfw with the LSI support (-l) on both sides.
           For example, you can start it with "hipfw -lAbk" flags. Also,
-          it is recommended to fix HITs and LSIs to /etc/hip/hosts
+          it is recommended to fix HITs and LSIs to @sysconfdir@/hosts
           and IP addresses to /etc/hosts at both sides. In this example,
           the NFS server has been configured to use LSI 1.0.0.1 and the
           client 1.0.0.2. Notice that the LSIs are valid only within the local
@@ -2482,7 +2482,7 @@
 
     <para>
      The DNS proxy tries to find host identities from two places:
-     "hosts" files (/etc/hosts and /etc/hip/hosts), HI records in DNS.
+     "hosts" files (/etc/hosts and @sysconfdir@/hosts), HI records in DNS.
      It returns the host identities as HITs or LSIs to the requesting
      application.
     </para>
@@ -2537,7 +2537,7 @@
       key file contents to different DNS zone file formats. To convert
       to unpatched BIND9 format, run the following:
       <programlisting>
-hipdnskeyparse &lt; /etc/hip/hip_host_rsa_key_pub.pub hostname.domain.org | 
sed -n -e '/^9BIND */s///p'
+hipdnskeyparse &lt; @sysconfdir@/hip_host_rsa_key_pub.pub hostname.domain.org 
| sed -n -e '/^9BIND */s///p'
       </programlisting>
       This outputs a line which can be inserted to a zone
       file. Similarly, with sed command:
@@ -2563,7 +2563,7 @@
     <para>
        Currently HIP daemon performs HIP name resolution in the following 
order:
       <itemizedlist>
-        <listitem><para>in /etc/hip/hosts</para></listitem>
+        <listitem><para>in @sysconfdir@/hosts</para></listitem>
         <listitem><para>in /etc/hosts</para></listitem>
         <listitem><para>in hit-to-ip.infrahip.net zone</para></listitem>
       </itemizedlist>
@@ -2575,7 +2575,7 @@
       to contact peer host with HIT 2001:1e:574e:2505:264a:b360:d8cc:1d75
     </para>
     <para>Default hit-to-ip.infrahip.net. suffix can be changed with
-      "hipconf hit-to-ip-set &lt;new.hit-to-ip.zone.&gt;. Please note it is 
independent from HIT_TO_IP_ZONE in /etc/hip/nsupdate.conf"
+      "hipconf hit-to-ip-set &lt;new.hit-to-ip.zone.&gt;. Please note it is 
independent from HIT_TO_IP_ZONE in @sysconfdir@/nsupdate.conf"
     </para>
     <para>
       With "hipconf nsupdate on", the HIP daemon also maintains
@@ -2660,10 +2660,10 @@
         NAT boxes to establish direct end-to-end connectivity with
         each other. The second mode, "full-relay" is supported
         completely and it relays both HIP and ESP traffic. You should
-        use it carefully and whitelist your /etc/hip/relay_config
+        use it carefully and whitelist your @sysconfdir@/relay_config
         file. Otherwise you risk your host becoming an open HIP and
         ESP relay. For additional security measure, you can also use
-        also /etc/hip/firewall_conf to further restrict the allowed
+        also @sysconfdir@/firewall_conf to further restrict the allowed
         clients and servers by their HITs.
        </para>
       <para>
@@ -2709,14 +2709,14 @@
       <abstract>
         <para>
           In this section, we show how to edit the configuration file:
-          "<emphasis>/etc/hip/relay_config</emphasis>".
+          "<emphasis>@sysconfdir@/relay_config</emphasis>".
         </para>
       </abstract>
       <section id="sec_relay_conf_about">
         <title>About the RVS and HIP Relay Configuration File</title>
         <para>
           The rendezvous server and the HIP relay server are configured using a
-          configuration file: "<emphasis>/etc/hip/relay_config</emphasis>".
+          configuration file: "<emphasis>@sysconfdir@/relay_config</emphasis>".
           Note, that this file is server side configuration file i.e. you only
           need to configure the file at the relay or rendezvous server, not at
           the client. This file is shared between the RVS and the HIP relay
@@ -2854,7 +2854,7 @@
         <para>
           Before you test the rendezvous mechanisms, you should have run the 
base
           exchange once without the rendezvous server to get familiar how the
-          "<emphasis>/etc/hosts</emphasis>" and 
"<emphasis>/etc/hip/hosts</emphasis>" files are configured. Please see
+          "<emphasis>/etc/hosts</emphasis>" and 
"<emphasis>@sysconfdir@/hosts</emphasis>" files are configured. Please see
           <xref linkend="ch_basictest" /> for information on how to run a base
           exchange without the rendezvous server. Also, before you can test the
           rendezvous mechanism, the configuration file must be edited
@@ -2884,7 +2884,7 @@
         </mediaobject>
         <para>
           First, the "<emphasis>/etc/hosts</emphasis>" and
-          "<emphasis>/etc/hip/hosts</emphasis>" files are configured. Please
+          "<emphasis>@sysconfdir@/hosts</emphasis>" files are configured. 
Please
           notice that you can leave all non-HIP-related values in
           "<emphasis>/etc/hosts</emphasis>" intact.
         </para>
@@ -2904,7 +2904,7 @@
               </listitem>
               <listitem>
                 <para>
-                  In the "<emphasis>/etc/hip/hosts</emphasis>" file you should 
have:
+                  In the "<emphasis>@sysconfdir@/hosts</emphasis>" file you 
should have:
                   &lt;RESPONDER HIT&gt; &lt;RESPONDER NAME&gt;. This is the 
line
                   that you would have in a normal base exchange execution not
                   involving an RVS. Please make sure that you use the same HIT
@@ -2921,7 +2921,7 @@
               <listitem>
                 <para>
                   Both files, "<emphasis>/etc/hosts</emphasis>" and
-                  "<emphasis>/etc/hip/hosts</emphasis>", are left blank. The 
files are left blank
+                  "<emphasis>@sysconfdir@/hosts</emphasis>", are left blank. 
The files are left blank
                   because the rendezvous server is assumed to have no 
information
                   of its clients beforehand. The RVS can have some white listed
                   HITs as beforehand information, however, but it is not 
required
@@ -2938,7 +2938,7 @@
               <listitem>
                 <para>
                   At the responder, both 
files,"<emphasis>/etc/hosts</emphasis>"
-                  and "<emphasis>/etc/hip/hosts</emphasis>", are left blank
+                  and "<emphasis>@sysconfdir@/hosts</emphasis>", are left blank
                   also. The responder is assumed to know the IP address and the
                   HIT of the rendezvous server, but this information is given 
as
                   command line parameters of the 
"<emphasis>hipconf</emphasis>" tool.
@@ -3116,7 +3116,7 @@
           Before you test the relay mechanisms, you should have run the base
           exchange once without the relay server to get familiar how the
           "<emphasis>/etc/hosts</emphasis>" and
-          "<emphasis>/etc/hip/hosts</emphasis>" files are configured. Please 
see
+          "<emphasis>@sysconfdir@/hosts</emphasis>" files are configured. 
Please see
           <xref linkend="ch_basictest" /> for information on how to run a base
           exchange without the relay server. Also, before you can test the
           relay mechanism, the configuration file must be edited
@@ -3156,7 +3156,7 @@
         </mediaobject>
         <para>
           First, the "<emphasis>/etc/hosts</emphasis>" and
-          "<emphasis>/etc/hip/hosts</emphasis>" files are configured. Please
+          "<emphasis>@sysconfdir@/hosts</emphasis>" files are configured. 
Please
           notice that you can leave all non-HIP-related values in
           "<emphasis>/etc/hosts</emphasis>" intact. The configuration of these
           files is identical with the RVS test case, thus if you have already
@@ -3387,7 +3387,7 @@
             <para>
               The server, on the other hand, uses the first given lifetime
               boundaries for every offered service in REG_INFO parameters
-              (If "<emphasis>/etc/hip/relay_config</emphasis>" would provide
+              (If "<emphasis>@sysconfdir@/relay_config</emphasis>" would 
provide
               a way to define individual lifetime boundaries for each service,
               the boundaries listed first would be used for every service).
             </para>
@@ -3484,7 +3484,7 @@
 
        <para>If firewall is killed, it leaves rules dangling which may drop
              some traffic. Check with "iptables -L -n" if there are some HIPFW
-             rules there and no hipfw running ("ps axu|grep hipfw"). You can
+             rules there and no hipfw running ("ps axu | grep hipfw"). You can
              flush the rules with "hipfw -k" and then pressing CTRL + C.
              Alternatively, you can just run "/etc/init.d/hipfw stop".
        </para>
@@ -3494,7 +3494,7 @@
         it drops all HIP traffic and allows all other traffic. You can change
         the defaults with hipfw command line flags. To get a list of command
         line flags, give the -h option to hipfw. When you start the firewall
-        the first time, it creates /etc/hip/firewall.conf file which contains
+        the first time, it creates @sysconfdir@/firewall.conf file which 
contains
         an example usage template.
         </para>
 
@@ -3783,7 +3783,7 @@
             enable/disable opportunistic mode. By default it is on.
     </para></listitem>
     <listitem><para>
-           Now the opportunistic mode is enabled. To test Opportunistic mode, 
you need to remove crash's HITs and name from /etc/hip/hosts, and then 
following the steps in <xref linkend="ch_basictest" />.
+           Now the opportunistic mode is enabled. To test Opportunistic mode, 
you need to remove crash's HITs and name from @sysconfdir@/hosts, and then 
following the steps in <xref linkend="ch_basictest" />.
     </para></listitem>
     </itemizedlist>
 
@@ -3911,7 +3911,7 @@
           getendpointinfo name resolution interface.</para>
       </listitem>
       <listitem>
-        <para>By default, the interface first checks the /etc/hip/hosts file 
for
+        <para>By default, the interface first checks the @sysconfdir@/hosts 
file for
           a matching host. If one is not found, the kernel is queried for its
           list of known HIP peers and the list is examined for matches.</para>
       </listitem>
@@ -3952,7 +3952,7 @@
 </programlisting>
 
     <para>
-    Notice that the last command can be also configured to /etc/hip/hipd_config
+    Notice that the last command can be also configured to 
@sysconfdir@/hipd_config
     </para>
 
     <para>
@@ -3970,53 +3970,6 @@
   </section>
   </section>
 
-  <section id="hipproxy">
-    <title>HIP Proxy</title>
-
-    <para>
-      It might not be possible to run HIP at all with old legacy
-      client hosts even with the userspace IPsec. In such a case, HIP
-      can be migrated to an on-path middlebox (e.g. router) by using the so
-      called HIP Proxy. The HIP proxy translates connections from
-      the client host to HIP-based connections to servers. The
-      extension is experimental. To try the proxy, you'll need three machines
-      as follows.
-    </para>
-
-    <para>
-      Start hipd at the server:
-    </para>
-
-    <programlisting>
-      hipd -bk
-    </programlisting>
-
-    <para>
-      Start hipd and hipfw on the on-path proxy in the proxy mode:
-    </para>
-
-   <programlisting>
-     hipd -bk
-     hipfw -Adbk
-     hipconf proxy on
-     &lt;make sure that openssh is running&gt;
-    </programlisting>
-
-    <para>
-      Connect with ssh from the client to the server:
-    </para>
-
-   <programlisting>
-     ssh &lt;ipv4-address-of-the-server&gt;
-    </programlisting>
-
-   <para>
-     The ssh connection should be tunneled over ESP. Note that this example
-     requires the proxy to be located on the path between the client and 
server.
-   </para>
-
-  </section>
-
   <section id="ch_shotgun">
     <title>"Shotgun" Extension</title>
 
@@ -4056,7 +4009,7 @@
 </programlisting>
 </para>
 
-    <para>The same line can be also included in /etc/hip/hipd_config
+    <para>The same line can be also included in @sysconfdir@/hipd_config
           without the "hipconf" prefix.
     </para>
 

=== modified file 'doc/doxygen.h'
--- doc/doxygen.h       2010-04-23 15:10:44 +0000
+++ doc/doxygen.h       2010-10-18 16:47:28 +0000
@@ -3,8 +3,6 @@
 /**
  * @file
  *
- * Distributed under <a href="http://www.gnu.org/licenses/gpl2.txt";>GNU/GPL</a>
- *
  * There should be no need to include this file anywhere! This is only for
  * defining doxygen related things, such as groups and lists.
  */

=== modified file 'firewall/cache.c'
--- firewall/cache.c    2010-08-20 14:34:13 +0000
+++ firewall/cache.c    2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * Caches partial information about hadb entries (HITs, LSIs, locators and HA 
state). Operates
  * independently of the firewall connection tracking feature.
  *
@@ -272,16 +273,26 @@
 }
 
 /**
- * Compare two HITs
- *
- * @param ptr1: pointer to a HIT
- * @param ptr2: pointer to a HIT
- *
- * @return zero if hashes are identical, or one otherwise
+ * Compare two cache table entries to resolve hash collisions.
+ *
+ * Note that when this function is called, the hashes of the two hash table
+ * entries provided as arguments are known to be equal.
+ * The point of this function is to allow the hash table to determine whether
+ * the entries (or rather the part used to calculate the hash) themselves are
+ * equal or whether they are different and this is just a hash collision.
+ *
+ * @param ptr1: pointer to a fw_cache_hl_t
+ * @param ptr2: pointer to a fw_cache_hl_t
+ *
+ * @return zero if the peer HITs in both table entries are identical, a 
non-zero value otherwise.
  */
 static int hip_firewall_match_hit_peer(const void *ptr1, const void *ptr2)
 {
-    return hip_firewall_hash_hit_peer(ptr1) != 
hip_firewall_hash_hit_peer(ptr2);
+    // stg: can one assume that there will always be at most one fw_cache_hl_t 
object per hit_peer?
+    // If so, one could compare the pointers instead because if the hit_peers 
are the same, the pointers would be the same, and comparing the pointers is 
faster.
+    const struct in6_addr *peer1 = &((const fw_cache_hl_t *) ptr1)->hit_peer;
+    const struct in6_addr *peer2 = &((const fw_cache_hl_t *) ptr2)->hit_peer;
+    return memcmp(peer1, peer2, sizeof(*peer1));
 }
 
 /**

=== modified file 'firewall/cache.h'
--- firewall/cache.h    2010-07-04 17:54:18 +0000
+++ firewall/cache.h    2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'firewall/cache_port.c'
--- firewall/cache_port.c       2010-07-29 08:51:54 +0000
+++ firewall/cache_port.c       2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * Cache TCP and UDP port information for incoming HIP-related connections for
  * LSIs. When hipfw sees an incoming HIT-based connection, it needs to figure 
out if
  * it needs to be translated to LSI or not. LSI translation is done only when 
there is
@@ -153,11 +154,11 @@
  */
 static int hip_port_cache_add_new_entry(const char *key, int value)
 {
-    firewall_port_cache_hl_t *new_entry = NULL;
+    struct firewall_port_cache_hl *new_entry = NULL;
     int err = 0;
 
     HIP_DEBUG("\n");
-    new_entry = (firewall_port_cache_hl_t *) (hip_cache_create_hl_entry());
+    new_entry = (struct firewall_port_cache_hl *) 
(hip_cache_create_hl_entry());
     memcpy(new_entry->port_and_protocol, key, strlen(key));
     new_entry->traffic_type = value;
     hip_ht_add(firewall_port_cache_db, new_entry);
@@ -173,10 +174,10 @@
  *
  * @return the cache entry if found or NULL otherwise
  */
-firewall_port_cache_hl_t *hip_firewall_port_cache_db_match(in_port_t port,
-                                                           int proto)
+struct firewall_port_cache_hl *hip_firewall_port_cache_db_match(in_port_t port,
+                                                                int proto)
 {
-    firewall_port_cache_hl_t *found_entry = NULL;
+    struct firewall_port_cache_hl *found_entry = NULL;
     char key[FIREWALL_PORT_CACHE_KEY_LENGTH];
     char protocol[10], proto_for_bind[10];
     int bindto = FIREWALL_PORT_CACHE_IPV4_TRAFFIC; //3 - default to ipv4, 
non-LSI traffic
@@ -238,7 +239,7 @@
     uint8_t hash[HIP_AH_SHA_LEN];
 
     key = (const char *)
-          &((const firewall_port_cache_hl_t *) ptr)->port_and_protocol;
+          &((const struct firewall_port_cache_hl *) ptr)->port_and_protocol;
     hip_build_digest(HIP_DIGEST_SHA1, key, sizeof(*key), hash);
     return *((unsigned long *) hash);
 }
@@ -246,14 +247,20 @@
 /**
  * Compare two keys for the hashtable
  *
+ * Note that when this function is called, the hashes of the two hash table
+ * entries provided as arguments are known to be equal.
+ * The point of this function is to allow the hash table to determine whether
+ * the entries (or rather the part used to calculate the hash) themselves are
+ * equal or whether they are different and this is just a hash collision.
+ *
  * @param ptr1 pointer to the first key
  * @param ptr2 pointer to the second key
  *
- * @return 0 if hashes identical, otherwise 1
+ * @return 0 if keys identical, otherwise != 0
  */
 static int hip_firewall_match_port_cache_key(const void *ptr1, const void 
*ptr2)
 {
-    return hip_firewall_port_hash_key(ptr1) != 
hip_firewall_port_hash_key(ptr2);
+    return strncmp((const char *)ptr1, (const char *)ptr2, 
FIREWALL_PORT_CACHE_KEY_LENGTH);
 }
 
 /**
@@ -273,9 +280,9 @@
 void hip_firewall_port_cache_uninit_hldb(void)
 {
     int i;
-    firewall_port_cache_hl_t *this = NULL;
-    hip_list_t *item               = NULL;
-    hip_list_t *tmp                = NULL;
+    struct firewall_port_cache_hl *this = NULL;
+    hip_list_t *item                    = NULL;
+    hip_list_t *tmp                     = NULL;
 
     HIP_DEBUG("Start hldb delete\n");
     HIP_LOCK_HT(&firewall_port_cache_db);
@@ -283,7 +290,7 @@
     list_for_each_safe(item, tmp, firewall_port_cache_db, i)
     {
       HIP_DEBUG("xx\n");
-        this = (firewall_port_cache_hl_t *) list_entry(item);
+        this = (struct firewall_port_cache_hl *) list_entry(item);
         hip_ht_delete(firewall_port_cache_db, this);
         free(this);
       HIP_DEBUG("yy\n");

=== modified file 'firewall/cache_port.h'
--- firewall/cache_port.h       2010-07-04 17:54:18 +0000
+++ firewall/cache_port.h       2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -33,8 +31,8 @@
 #include "lib/core/icomm.h"
 
 void hip_firewall_port_cache_init_hldb(void);
-firewall_port_cache_hl_t *hip_firewall_port_cache_db_match(in_port_t port,
-                                                           int proto);
+struct firewall_port_cache_hl *hip_firewall_port_cache_db_match(in_port_t port,
+                                                                int proto);
 void hip_firewall_port_cache_uninit_hldb(void);
 
 #endif /* HIP_CACHE_H */

=== modified file 'firewall/common_types.h'
--- firewall/common_types.h     2010-07-04 17:54:18 +0000
+++ firewall/common_types.h     2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'firewall/conntrack.c'
--- firewall/conntrack.c        2010-09-06 11:51:23 +0000
+++ firewall/conntrack.c        2010-10-27 11:27:48 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * Connection tracker for HIP and ESP. It is inspired by the connection 
tracker in the Linux kernel. See the following publications for more details:
  * - <a href="http://hipl.hiit.fi/papers/essi_dippa.pdf";>E. Vehmersalo, Host 
Identity Protocol Enabled Firewall: A Prototype Implementation and Analysis, 
Master's thesis, September 2005</a>
  * - <a href="http://www.usenix.org/events/usenix07/poster.html";>Lindqvist, 
Janne; Vehmersalo, Essi; Komu, Miika; Manner, Jukka, Enterprise Network Packet 
Filtering for Mobile Cryptographic Identities,
@@ -38,6 +39,7 @@
 
 #define _BSD_SOURCE
 
+#include <errno.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
@@ -577,10 +579,9 @@
             list              = tuple->esp_tuples;
         }
         tuple->esp_tuples = NULL;
-
         tuple->connection = NULL;
+
         // tuple was not malloced -> no free here
-
         if (tuple->src_ip) {
             free(tuple->src_ip);
             tuple->src_ip = NULL;
@@ -853,13 +854,10 @@
 
     /* Store Responder's IP address and port */
     tuple->esp_relay = 1;
-    ipv6_addr_copy(&tuple->esp_relay_daddr,
-                   &ctx->src);
+    ipv6_addr_copy(&tuple->esp_relay_daddr, &ctx->src);
     tuple->esp_relay_dport = tuple->dst_port;
-    HIP_DEBUG("tuple relay port=%d\n",
-              tuple->esp_relay_dport);
-    HIP_DEBUG_IN6ADDR("tuple relay ip",
-                      &tuple->esp_relay_daddr);
+    HIP_DEBUG("tuple relay port=%d\n", tuple->esp_relay_dport);
+    HIP_DEBUG_IN6ADDR("tuple relay ip", &tuple->esp_relay_daddr);
 
     /* Store Initiator's IP address and port */
     reverse_tuple->esp_relay = 1;
@@ -961,10 +959,10 @@
                      const hip_fw_context_t *ctx)
 {
     const struct hip_esp_info *spi    = NULL;
+    const SList *other_dir_esps       = NULL;
+    const struct hip_host_id *host_id = NULL;
     struct tuple *other_dir           = NULL;
     struct esp_tuple *esp_tuple       = NULL;
-    SList *other_dir_esps             = NULL;
-    const struct hip_host_id *host_id = NULL;
     struct in6_addr hit;
     // assume correct packet
     int err                     = 1;

=== modified file 'firewall/conntrack.h'
--- firewall/conntrack.h        2010-07-04 17:54:18 +0000
+++ firewall/conntrack.h        2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'firewall/dlist.c'
--- firewall/dlist.c    2010-09-03 11:40:19 +0000
+++ firewall/dlist.c    2010-11-09 16:37:54 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * Two-way linked list implementation operating based on pointers. It is
  * recommended to use lib/core/list.h implementation which supports
  * searching based on indexes (rather than pointers) can later also be

=== modified file 'firewall/dlist.h'
--- firewall/dlist.h    2010-07-04 17:54:18 +0000
+++ firewall/dlist.h    2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'firewall/esp_prot_api.c'
--- firewall/esp_prot_api.c     2010-07-29 08:42:46 +0000
+++ firewall/esp_prot_api.c     2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This is the  implementation of the API for adding and verifying
  * tokens to ESP data packets for the different modes, in order to
  * allow middleboxes to inspect and verify the validity of ESP
@@ -32,7 +33,6 @@
  * @brief Provides API to token-based ESP protection for middleboxes
  *
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #include <math.h>

=== modified file 'firewall/esp_prot_api.h'
--- firewall/esp_prot_api.h     2010-07-04 17:54:18 +0000
+++ firewall/esp_prot_api.h     2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * API for adding and verifying tokens to ESP data packets for the
  * different modes, in order to allow middleboxes to inspect and
  * verify the validity of ESP packets.
@@ -31,7 +32,6 @@
  * @brief Provides API to token-based ESP protection for middleboxes
  *
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #ifndef HIP_FIREWALL_ESP_PROT_API_H

=== modified file 'firewall/esp_prot_config.c'
--- firewall/esp_prot_config.c  2010-07-07 09:37:49 +0000
+++ firewall/esp_prot_config.c  2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This implements reading of the configuration files for the
  * ESP protection extension. It furthermore provides sanity
  * checks on the passed values.
@@ -31,7 +32,6 @@
  * @brief Reads the config file for the ESP protection extension
  *
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #define _BSD_SOURCE
@@ -46,26 +46,23 @@
 #include "config.h"
 
 
-const char *config_file = {"/etc/hip/esp_prot_config.cfg"};
-
-const char *path_token_transform = {"token_config.token_transform"};
-
-const char *path_num_parallel_hchains = 
{"token_config.token_modes.num_parallel_hchains"};
-
-const char *path_ring_buffer_size = 
{"token_config.token_modes.ring_buffer_size"};
-const char *path_num_linear_elements = 
{"token_config.token_modes.num_linear_elements"};
-const char *path_num_random_elements = 
{"token_config.token_modes.num_random_elements"};
-
-const char *path_hash_length = {"token_config.hash_length"};
-const char *path_hash_structure_length = 
{"token_config.hash_structure_length"};
-
-
-const char *path_num_hchains_per_item = 
{"sender.hcstore.num_hchains_per_item"};
-const char *path_num_hierarchies = {"sender.hcstore.num_hierarchies"};
-const char *path_refill_threshold = {"sender.hcstore.refill_threshold"};
-const char *path_update_threshold = {"sender.update_threshold"};
-
-const char *path_window_size = {"verifier.window_size"};
+const char *config_file                = HIPL_SYSCONFDIR 
"/esp_prot_config.cfg";
+
+const char *path_hash_length           = "token_config.hash_length";
+const char *path_hash_structure_length = "token_config.hash_structure_length";
+const char *path_token_transform       = "token_config.token_transform";
+
+const char *path_num_parallel_hchains  = 
"token_config.token_modes.num_parallel_hchains";
+const char *path_ring_buffer_size      = 
"token_config.token_modes.ring_buffer_size";
+const char *path_num_linear_elements   = 
"token_config.token_modes.num_linear_elements";
+const char *path_num_random_elements   = 
"token_config.token_modes.num_random_elements";
+
+const char *path_num_hchains_per_item  = "sender.hcstore.num_hchains_per_item";
+const char *path_num_hierarchies       = "sender.hcstore.num_hierarchies";
+const char *path_refill_threshold      = "sender.hcstore.refill_threshold";
+const char *path_update_threshold      = "sender.update_threshold";
+
+const char *path_window_size           = "verifier.window_size";
 
 #ifdef HAVE_LIBCONFIG
 /**
@@ -124,7 +121,7 @@
     config_init(cfg);
     HIP_DEBUG("reading config file: %s\n", config_file);
     HIP_IFEL(!config_read_file(cfg, config_file), -1,
-             "unable to read config file, please ensure that 
esp_prot_config.cfg is located in /etc/hip/\n");
+             "unable to read config file, please ensure that 
esp_prot_config.cfg is located in " HIPL_SYSCONFDIR "\n");
 
 out_err:
     if (err) {

=== modified file 'firewall/esp_prot_config.h'
--- firewall/esp_prot_config.h  2010-07-04 17:54:18 +0000
+++ firewall/esp_prot_config.h  2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * API for reading of the configuration files for the
  * ESP protection extension. It furthermore provides sanity
  * checks on the passed values.
@@ -31,7 +32,6 @@
  * @brief Reads the config file for the ESP protection extension
  *
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #ifndef HIP_FIREWALL_ESP_PROT_CONFIG_H

=== modified file 'firewall/esp_prot_conntrack.c'
--- firewall/esp_prot_conntrack.c       2010-08-19 09:32:20 +0000
+++ firewall/esp_prot_conntrack.c       2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,14 +21,16 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This implements the connection tracking for the ESP
  * protection extension.
  *
  * @brief Connection tracking extension needed for the ESP protection extension
  *
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #define _BSD_SOURCE

=== modified file 'firewall/esp_prot_conntrack.h'
--- firewall/esp_prot_conntrack.h       2010-07-04 17:54:18 +0000
+++ firewall/esp_prot_conntrack.h       2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,13 +21,15 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * API for the connection tracking for the ESP protection extension.
  *
  * @brief Connection tracking extension needed for the ESP protection extension
  *
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #ifndef HIP_FIREWALL_ESP_PROT_CONNTRACK_H

=== modified file 'firewall/esp_prot_defines.h'
--- firewall/esp_prot_defines.h 2010-07-04 17:54:18 +0000
+++ firewall/esp_prot_defines.h 2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'firewall/esp_prot_fw_msg.c'
--- firewall/esp_prot_fw_msg.c  2010-10-19 21:29:10 +0000
+++ firewall/esp_prot_fw_msg.c  2010-11-09 16:37:54 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This implements the communication with the hipd.
  *
  * @brief TPA and HHL-specific inter-process communication with the hipd

=== modified file 'firewall/esp_prot_fw_msg.h'
--- firewall/esp_prot_fw_msg.h  2010-07-04 17:54:18 +0000
+++ firewall/esp_prot_fw_msg.h  2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,13 +21,15 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * API for the communication with the hipd.
  *
  * @brief TPA and HHL-specific inter-process communication with the hipd
  *
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #ifndef HIP_FIREWALL_ESP_PROT_FW_MSG_H

=== modified file 'firewall/firewall.c'
--- firewall/firewall.c 2010-08-30 08:28:41 +0000
+++ firewall/firewall.c 2010-10-15 15:29:14 +0000
@@ -1,6 +1,5 @@
-/** @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -22,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * All functionality that requires packet capture using libipq are contained 
in the
  * hipfw. The basic function of the hipfw is to track HIP packets and track 
associate
  * them with the related ESP connections with SPIs. This way, the hipfw can 
support access control
@@ -242,7 +244,7 @@
     struct utsname name;
 
     HIP_IFEL(uname(&name), -1, "Failed to retrieve kernel information: %s\n",
-             strerror(err));
+             strerror(errno));
     ver_c = atoi(&name.release[4]);
 
     if (hip_userspace_ipsec) {
@@ -531,8 +533,7 @@
         system_print("ip6tables -I HIPFW-OUTPUT -p 17 --sport 10500 -j QUEUE");
     }
 
-    HIP_IFEL(hip_fw_init_system_based_opp_mode(),
-             -1, "failed to load extension\n");
+    HIP_IFEL(hip_fw_init_system_based_opp_mode(), -1, "failed to load 
extension\n");
     HIP_IFEL(hip_fw_init_lsi_support(), -1, "failed to load extension\n");
     HIP_IFEL(hip_fw_init_userspace_ipsec(), -1, "failed to load extension\n");
     HIP_IFEL(hip_fw_init_esp_prot(), -1, "failed to load extension\n");
@@ -620,7 +621,6 @@
 
 /**
  * Uninitialize all basic and extended packet capture rules
- *
  */
 static void hip_fw_flush_iptables(void)
 {
@@ -658,7 +658,6 @@
 /**
  * Firewall signal handler (SIGINT, SIGTERM). Exit firewall gracefully
  * and clean up all packet capture rules.
- *
  */
 static void firewall_exit(void)
 {
@@ -666,12 +665,13 @@
 
     HIP_DEBUG("Firewall exit\n");
 
-    msg = hip_msg_alloc();
-    if (hip_build_user_hdr(msg, HIP_MSG_FIREWALL_QUIT, 0) ||
-        hip_send_recv_daemon_info(msg, 1, hip_fw_sock)) {
-        HIP_DEBUG("Failed to notify hipd of firewall shutdown.\n");
+    if ((msg = hip_msg_alloc()) != NULL) {
+        if (hip_build_user_hdr(msg, HIP_MSG_FIREWALL_QUIT, 0) ||
+            hip_send_recv_daemon_info(msg, 1, hip_fw_sock)) {
+            HIP_DEBUG("Failed to notify hipd of firewall shutdown.\n");
+        }
+        free(msg);
     }
-    free(msg);
 
     hip_firewall_cache_delete_hldb(1);
     hip_firewall_port_cache_uninit_hldb();
@@ -704,14 +704,6 @@
     exit(EXIT_SUCCESS);
 }
 
-static void die(struct ipq_handle *h)
-{
-    HIP_DEBUG("Dying by sending SIGTERM to self\n");
-    ipq_perror("passer");
-    ipq_destroy_handle(h);
-    kill(getpid(), SIGTERM);
-}
-
 /**
  * Increases the netlink buffer capacity.
  *
@@ -1308,8 +1300,8 @@
 }
 
 /**
- * Process an other (not HIP, ESP, TCP) packet from the inbound packet capture
- * queue
+ * Process another (not HIP, ESP, TCP) packet from the inbound packet
+ * capture queue. May result in LSI or SysOPP Transformation.
  *
  * @param ctx the packet context
  *
@@ -1486,7 +1478,7 @@
  *
  * @param  ctx        the context.
  * @param  buf        a pointer to a IP packet.
- * @param ip_version  the IP version for this packet
+ * @param  ip_version the IP version for this packet
  * @return            One if @c hdr is a HIP packet, zero otherwise.
  */
 static int hip_fw_init_context(hip_fw_context_t *ctx,
@@ -1805,7 +1797,7 @@
  * @param ctx packet context
  *
  * @return  nothing, this function loops forever,
- *      until the firewall is stopped.
+ *          until the firewall is stopped.
  */
 static int hip_fw_handle_packet(unsigned char *buf,
                                 struct ipq_handle *hndl,
@@ -1925,11 +1917,12 @@
  *
  * @return zero on success and non-zero on failure
  *
+ * @todo   Set up atexit() for clean shutdown on HIP_ASSERT.
  */
 int main(int argc, char **argv)
 {
     int err                = 0, highest_descriptor, i;
-    int status, n, len;
+    int n, len;
     struct ipq_handle *h4  = NULL, *h6 = NULL;
     int ch;
     char *rule_file        = NULL;
@@ -2049,11 +2042,11 @@
             return 0;
         case ':':         /* option without operand */
             printf("Option -%c requires an operand\n", optopt);
-            errflg++;
+            errflg = 1;
             break;
         case '?':
             printf("Unrecognized option: -%c\n", optopt);
-            errflg++;
+            errflg = 1;
         }
     }
 
@@ -2084,7 +2077,7 @@
 
     for (i=0; i<2; i++) {
         err = bind(hip_fw_sock, (struct sockaddr *)& sock_addr,
-               sizeof(sock_addr));
+                   sizeof(sock_addr));
         if (err == 0) {
             break;
         } else if (err && i == 0) {
@@ -2093,8 +2086,7 @@
     }
 
     HIP_IFEL(err, -1, "Bind on firewall socket addr failed. Give -k option to 
kill old hipfw\n");
-    HIP_IFEL(hip_daemon_connect(hip_fw_sock), -1,
-         "connecting socket failed\n");
+    HIP_IFEL(hip_daemon_connect(hip_fw_sock), -1, "connecting socket 
failed\n");
 
     /* Only for receiving out-of-sync notifications from hipd  */
     hip_fw_async_sock = socket(AF_INET6, SOCK_DGRAM, 0);
@@ -2103,10 +2095,10 @@
     sock_addr.sin6_family = AF_INET6;
     sock_addr.sin6_port = htons(HIP_FIREWALL_PORT);
     sock_addr.sin6_addr = in6addr_loopback;
-    HIP_IFEL(bind(hip_fw_async_sock, (struct sockaddr *)& sock_addr,
-              sizeof(sock_addr)), -1, "Bind on firewall socket addr failed. 
Give -k option to kill old hipfw\n");
+    HIP_IFEL(bind(hip_fw_async_sock, (struct sockaddr *)& sock_addr, 
sizeof(sock_addr)), -1,
+             "Bind on firewall socket addr failed. Give -k option to kill old 
hipfw\n");
     HIP_IFEL(hip_daemon_connect(hip_fw_async_sock), -1,
-         "connecting socket failed\n");
+             "connecting socket failed\n");
 
     /* Starting hipfw does not always work when hipfw starts first -miika */
     if (hip_userspace_ipsec || hip_lsi_support || system_based_opp_mode) {
@@ -2127,63 +2119,37 @@
     firewall_probe_kernel_modules();
 
     // create firewall queue handles for IPv4 traffic
-    // FIXME died handle will still be used below
-    // FIXME memleak - not free'd on exit
-    h4 = ipq_create_handle(0, PF_INET);
-
-    if (!h4) {
-        die(h4);
-    }
-
-    HIP_DEBUG("IPv4 handle created\n");
-
-    status = ipq_set_mode(h4, IPQ_COPY_PACKET, HIP_MAX_PACKET);
-
-    if (status < 0) {
-        die(h4);
-    }
-    HIP_DEBUG("IPv4 handle mode COPY_PACKET set\n");
+    HIP_IFEL(!(h4 = ipq_create_handle(0, PF_INET)), -1,
+             "ipq_create_handle(): %s\n", ipq_errstr());
+    HIP_IFEL(ipq_set_mode(h4, IPQ_COPY_PACKET, HIP_MAX_PACKET) == -1, -1,
+             "ipq_set_mode(): %s\n", ipq_errstr());
+    HIP_DEBUG("IPv4 handle created (mode COPY_PACKET)\n");
 
     // create firewall queue handles for IPv6 traffic
-    // FIXME died handle will still be used below
-    // FIXME memleak - not free'd on exit
-    h6 = ipq_create_handle(0, PF_INET6);
-
-    if (!h6) {
-        die(h6);
-    }
-    HIP_DEBUG("IPv6 handle created\n");
-    status = ipq_set_mode(h6, IPQ_COPY_PACKET, HIP_MAX_PACKET);
-
-    if (status < 0) {
-        die(h6);
-    }
-    HIP_DEBUG("IPv6 handle mode COPY_PACKET set\n");
+    HIP_IFEL(!(h6 = ipq_create_handle(0, PF_INET6)), -1,
+             "ipq_create_handle(): %s\n", ipq_errstr());
+    HIP_IFEL(ipq_set_mode(h6, IPQ_COPY_PACKET, HIP_MAX_PACKET) == -1, -1,
+             "ipq_set_mode(): %s\n", ipq_errstr());
+    HIP_DEBUG("IPv6 handle created (mode COPY_PACKET)\n");
 
     // set up ip(6)tables rules and firewall extensions
     HIP_IFEL(firewall_init(), -1, "Firewall init failed\n");
 
-    /* Allocate message. */
-    // FIXME memleak - not free'd on exit
-    msg = hip_msg_alloc();
-    if (!msg) {
-        err = -1;
-        return err;
-    }
-
     if (limit_capabilities) {
-        HIP_IFEL(hip_set_lowcapability(), -1, "Failed to reduce priviledges");
+        HIP_IFEL(hip_set_lowcapability(), -1, "Failed to reduce privileges\n");
     }
 
     highest_descriptor = maxof(3, hip_fw_async_sock, h4->fd, h6->fd);
 
+    /* Allocate message. */
+    HIP_IFEL(!(msg = hip_msg_alloc()), -1, "Insufficient memory\n");
+
     hip_msg_init(msg);
     HIP_IFEL(hip_build_user_hdr(msg, HIP_MSG_FIREWALL_START, 0), -1,
              "build user hdr\n");
     if (hip_send_recv_daemon_info(msg, 1, hip_fw_sock)) {
         HIP_DEBUG("Failed to notify hipd of firewall start.\n");
     }
-    hip_msg_init(msg);
 
     // let's show that the firewall is running even with debug NONE
     HIP_DEBUG("firewall running. Entering select loop.\n");
@@ -2205,7 +2171,7 @@
         // get handle with queued packet and process
         /* @todo: using HIPD_SELECT blocks hipfw with R1 */
         if ((err = select((highest_descriptor + 1), &read_fdset,
-                       NULL, NULL, &timeout)) < 0) {
+                          NULL, NULL, &timeout)) < 0) {
             HIP_PERROR("select error, ignoring\n");
             continue;
         }
@@ -2294,6 +2260,12 @@
     }
 
 out_err:
+    if (h4) {
+        ipq_destroy_handle(h4);
+    }
+    if (h6) {
+        ipq_destroy_handle(h6);
+    }
     if (hip_fw_async_sock) {
         close(hip_fw_async_sock);
     }
@@ -2305,7 +2277,7 @@
     }
 
     firewall_exit();
-    return 0;
+    return err;
 }
 
 /*----------------EXTERNALLY USED FUNCTIONS-------------------*/

=== modified file 'firewall/firewall.h'
--- firewall/firewall.h 2010-07-04 17:54:18 +0000
+++ firewall/firewall.h 2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'firewall/firewall_control.c'
--- firewall/firewall_control.c 2010-08-20 14:34:13 +0000
+++ firewall/firewall_control.c 2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * Firewall communication interface with hipd. Firewall can send messages
  * asynchronously (recommended) or synchronously (not recommended because
  * other messages may intervene).

=== modified file 'firewall/firewall_control.h'
--- firewall/firewall_control.h 2010-07-04 17:54:18 +0000
+++ firewall/firewall_control.h 2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'firewall/firewall_defines.h'
--- firewall/firewall_defines.h 2010-09-03 11:40:19 +0000
+++ firewall/firewall_defines.h 2010-11-09 16:37:54 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -57,15 +55,15 @@
     struct in6_addr   src, dst;
     union {
         struct ip6_hdr *ipv6;
-        struct ip *     ipv4;
+        struct ip      *ipv4;
     } ip_hdr;
 
     // transport layer information
     int packet_type;     /* HIP_PACKET, ESP_PACKET, etc  */
     union {
-        struct hip_esp *   esp;
+        struct hip_esp    *esp;
         struct hip_common *hip;
-        struct tcphdr *    tcp;
+        struct tcphdr     *tcp;
     } transport_hdr;
     struct udphdr *udp_encap_hdr;
 
@@ -75,8 +73,8 @@
 /********** State table structures **************/
 
 struct esp_address {
-    struct in6_addr dst_addr;
-    uint32_t *      update_id; // null or pointer to the update id from the 
packet
+    struct in6_addr  dst_addr;
+    uint32_t        *update_id; // null or pointer to the update id from the 
packet
     // that announced this address.
     // when ack with the update id is seen all esp_addresses with
     // null update_id can be removed.
@@ -86,8 +84,8 @@
     uint32_t                spi;
     uint32_t                new_spi;
     uint32_t                spi_update_id;
-    SList *                 dst_addr_list;
-    struct tuple *          tuple;
+    SList                  *dst_addr_list;
+    struct tuple           *tuple;
     /* tracking of the ESP SEQ number */
     uint32_t                seq_no;
     /* members needed for ESP protection extension */
@@ -100,9 +98,9 @@
     unsigned char           
first_active_anchors[MAX_NUM_PARALLEL_HCHAINS][MAX_HASH_LENGTH];
     unsigned char           
next_anchors[MAX_NUM_PARALLEL_HCHAINS][MAX_HASH_LENGTH];
     int                     active_root_length;
-    unsigned char *         active_roots[MAX_NUM_PARALLEL_HCHAINS];
+    unsigned char          *active_roots[MAX_NUM_PARALLEL_HCHAINS];
     int                     next_root_length[MAX_NUM_PARALLEL_HCHAINS];
-    unsigned char *         next_roots[MAX_NUM_PARALLEL_HCHAINS];
+    unsigned char          *next_roots[MAX_NUM_PARALLEL_HCHAINS];
     /* list temporarily storing anchor elements until the consecutive update
      * msg reveals that all on-path devices know the new anchor */
     hip_ll_t                anchor_cache;
@@ -114,22 +112,22 @@
     struct in6_addr     src_hit;
     struct in6_addr     dst_hit;
     struct hip_host_id *src_hi;
-    void *              src_pub_key;
+    void               *src_pub_key;
     int                 (*verify)(void *, struct hip_common *);
 };
 
 struct hip_tuple {
     struct hip_data *data;
-    struct tuple *   tuple;
+    struct tuple    *tuple;
 };
 
 struct tuple {
-    struct hip_tuple * hip_tuple;
-    struct in6_addr *  src_ip;
-    struct in6_addr *  dst_ip;
+    struct hip_tuple  *hip_tuple;
+    struct in6_addr   *src_ip;
+    struct in6_addr   *dst_ip;
     in_port_t          src_port;
     in_port_t          dst_port;
-    SList *            esp_tuples;
+    SList             *esp_tuples;
     int                direction;
     struct connection *connection;
     int                state;

=== modified file 'firewall/helpers.c'
--- firewall/helpers.c  2010-07-19 16:00:22 +0000
+++ firewall/helpers.c  2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * @brief Few "utility" functions for the firewall
  *
  * @author Essi Vehmersalo

=== modified file 'firewall/helpers.h'
--- firewall/helpers.h  2010-07-19 16:00:22 +0000
+++ firewall/helpers.h  2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'firewall/hslist.c'
--- firewall/hslist.c   2010-07-04 17:54:18 +0000
+++ firewall/hslist.c   2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * One-way linked list implementation operating based on pointers. It is
  * recommended to use lib/core/list.h implementation which supports
  * searching based on indexes (rather than pointers) can later also be
@@ -39,8 +40,6 @@
 #include "common_types.h"
 #include "hslist.h"
 
-static SList *slist_last(SList *list);
-
 /**
  * allocate a new linked list element
  *
@@ -55,6 +54,22 @@
 }
 
 /**
+ * traverse to the last element of the linked list
+ *
+ * @param list the linked list to be traversed
+ * @return the last element of the linked list
+ */
+static SList *slist_last(SList *list)
+{
+    if (list) {
+        while (list->next) {
+            list = list->next;
+        }
+    }
+    return list;
+}
+
+/**
  * append an element to the linked list
  *
  * @param list the linked list
@@ -81,22 +96,6 @@
 }
 
 /**
- * traverse to the last element of the linked list
- *
- * @param list the linked list to be traversed
- * @return the last element of the linked list
- */
-static SList *slist_last(SList *list)
-{
-    if (list) {
-        while (list->next) {
-            list = list->next;
-        }
-    }
-    return list;
-}
-
-/**
  * remove a linked list item from a list (no deallocation)
  *
  * @param list the linked list

=== modified file 'firewall/hslist.h'
--- firewall/hslist.h   2010-07-04 17:54:18 +0000
+++ firewall/hslist.h   2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -30,10 +28,8 @@
 
 #include "common_types.h"
 
-SList *append_to_slist(SList *list,
-                       void *data);
+SList *append_to_slist(SList *list, void *data);
 
-SList *remove_link_slist(SList *list,
-                         SList *link);
+SList *remove_link_slist(SList *list, SList *link);
 
 #endif /* HIP_FIREWALL_HSLIST_H */

=== modified file 'firewall/lsi.c'
--- firewall/lsi.c      2010-08-20 14:34:13 +0000
+++ firewall/lsi.c      2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This file provides translation between HITs and LSIs. Outgoing
  * LSI-based packets are all captured, translated to HIT-based packets
  * and reinjected back to the networking stack for delivery. Incoming
@@ -311,16 +312,16 @@
                                const struct in6_addr *ip_dst,
                                const int lsi_support)
 {
-    int err                                    = 0;
-    int verdict                                = 1;
-    int ip_hdr_size                            = 0;
-    int portDest                               = 0;
-    int process_as_lsi                         = 0;
+    int err                                               = 0;
+    int verdict                                           = 1;
+    int ip_hdr_size                                       = 0;
+    int portDest                                          = 0;
+    int process_as_lsi                                    = 0;
+    fw_cache_hl_t *entry                                  = NULL;
+    const struct firewall_port_cache_hl *port_cache_entry = NULL;
+    const struct ip6_hdr *ip6_hdr                         = NULL;
     char proto[PROTO_STRING_MAX];
     struct in6_addr src_addr, dst_addr;
-    const struct ip6_hdr *ip6_hdr;
-    firewall_port_cache_hl_t *port_cache_entry = NULL;
-    fw_cache_hl_t *entry                       = NULL;
 
     ip6_hdr = (const struct ip6_hdr *) m->payload;
     ip_hdr_size = sizeof(struct ip6_hdr);

=== modified file 'firewall/lsi.h'
--- firewall/lsi.h      2010-07-04 17:54:18 +0000
+++ firewall/lsi.h      2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'firewall/midauth.c'
--- firewall/midauth.c  2010-08-19 10:43:06 +0000
+++ firewall/midauth.c  2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This file provides a framework for modifying HIP packets. It includes
  * adding new parameters in the correct order and adapting the various
  * headers.

=== modified file 'firewall/midauth.h'
--- firewall/midauth.h  2010-07-04 17:54:18 +0000
+++ firewall/midauth.h  2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,11 +21,11 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
- * @brief The header file for firewall/midauth.c
- * *
+ */
+
+/**
+ * @file
  * @author Thomas Jansen
- *
  */
 
 #ifndef HIP_FIREWALL_MIDAUTH_H

=== modified file 'firewall/pisa.c'
--- firewall/pisa.c     2010-08-19 10:43:06 +0000
+++ firewall/pisa.c     2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,13 +21,16 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This file contains PISA specific functions for the firewall. The basic idea
  * is to modify the HIP messages and manage state for allowed connections to
  * allow or reject associated ESP traffic.
  *
  * @brief PISA functions for the firewall
- * *
+ *
  * @author Thomas Jansen
  * @author Dominic Gatzen
  */
@@ -78,7 +79,7 @@
 
 /* @todo make this configurable, issuer HIT */
 #define CO_HIT "2001:001a:b1b0:0aad:0f92:15ca:280c:9430"
-#define CO_HIT_FILE "/etc/hip/co_hit"
+#define CO_HIT_FILE HIPL_SYSCONFDIR "/co_hit"
 
 /**
  * Generate a new random number and shift the old one down.

=== modified file 'firewall/pisa.h'
--- firewall/pisa.h     2010-07-04 17:54:18 +0000
+++ firewall/pisa.h     2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,9 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
- * @brief A header file for pisa.c
- *
+ */
+
+/**
+ * @file
  * @author Thomas Jansen
  */
 

=== modified file 'firewall/pisa_cert.c'
--- firewall/pisa_cert.c        2010-07-04 17:54:18 +0000
+++ firewall/pisa_cert.c        2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,12 +21,15 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This file deals with the PISA specific handling of SPKI certificates. The
  * certificate is parsed and split into small chunks.
  *
  * @brief PISA handling for SPKI certificates
- * *
+ *
  * @author Thomas Jansen
  */
 

=== modified file 'firewall/pisa_cert.h'
--- firewall/pisa_cert.h        2010-07-04 17:54:18 +0000
+++ firewall/pisa_cert.h        2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,9 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
- * @brief The header file for firewall/pisa_cert.c
- *
+ */
+
+/**
+ * @file
  * @author Thomas Jansen
  */
 

=== modified file 'firewall/reinject.c'
--- firewall/reinject.c 2010-07-07 16:48:07 +0000
+++ firewall/reinject.c 2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,10 +21,12 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * Sockets and functions for reinjection of packets.
- *
-*/
+ */
 
 #define _BSD_SOURCE
 

=== modified file 'firewall/reinject.h'
--- firewall/reinject.h 2010-07-07 16:48:07 +0000
+++ firewall/reinject.h 2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'firewall/rule_management.c'
--- firewall/rule_management.c  2010-09-02 19:33:25 +0000
+++ firewall/rule_management.c  2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * Writes a default firewall ACL configuration file. Reads and parses
  * the configuration from disk to memory.
  *
@@ -129,7 +130,7 @@
     ssize_t items;
     int i    = 0;
 
-    /* Firewall depends on hipd to create /etc/hip */
+    /* Firewall depends on hipd to create HIPL_SYSCONFDIR */
     for (i = 0; i < 5; i++) {
         if (stat(HIPL_SYSCONFDIR, &status) &&
             errno == ENOENT) {
@@ -145,7 +146,7 @@
         HIP_DIE("Please start hipd or execute 'hipd -c'\n");
     }
 
-    rename("/etc/hip/firewall.conf", HIP_FW_DEFAULT_RULE_FILE);
+    rename(HIPL_SYSCONFDIR "/firewall.conf", HIP_FW_DEFAULT_RULE_FILE);
 
     if (stat(file, &status) && errno == ENOENT) {
         errno = 0;

=== modified file 'firewall/rule_management.h'
--- firewall/rule_management.h  2010-07-04 17:54:18 +0000
+++ firewall/rule_management.h  2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -50,14 +48,14 @@
 };
 
 struct int_option {
-    int value; //int value
-    int boolean; // 0 if negation, else 1
+    int value;   /**< int value */
+    int boolean; /**< 0 if negation, else 1 */
 };
 
 struct state_option {
     struct int_option int_opt;
-    int verify_responder; //1 if responder signatures are verified
-    int accept_mobile; //1 if state can be established from updates signalling
+    int verify_responder; /**< 1 if responder signatures are verified */
+    int accept_mobile;    /**< 1 if state can be established from updates 
signalling */
     int decrypt_contents;
 };
 
@@ -68,10 +66,10 @@
     int boolean;
 };
 
-//Pointer values must be NULL if option is not specified.
-//Use alloc_empty_rule() to allocate rule with pointers set to NULL!!
-//when updating rule structure, update also (at least) free_rule(),
-//print_rule(), rules_equal(), copy_rule (), alloc_empty_rule() functions
+// Pointer values must be NULL if option is not specified.
+// Use alloc_empty_rule() to allocate rule with pointers set to NULL!!
+// when updating rule structure, update also (at least) free_rule(),
+// print_rule(), rules_equal(), copy_rule (), alloc_empty_rule() functions
 struct rule {
     struct hit_option *src_hit;
     struct hit_option *dst_hit;

=== modified file 'firewall/sysopp.c'
--- firewall/sysopp.c   2010-08-19 09:32:20 +0000
+++ firewall/sysopp.c   2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * System-based opportunistic mode for HIP. In contrast to the library-based
  * opportunistic mode, this code hooks by iptables instead of LD_PRELOAD.
  * See the following papers for more information:

=== modified file 'firewall/sysopp.h'
--- firewall/sysopp.h   2010-07-04 17:54:18 +0000
+++ firewall/sysopp.h   2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'firewall/user_ipsec_api.c'
--- firewall/user_ipsec_api.c   2010-07-04 17:54:18 +0000
+++ firewall/user_ipsec_api.c   2010-10-27 11:27:48 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,13 +21,15 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This implementation provides the API for userspace IPsec.
  *
  * @brief API for the userspace IPsec functionality
  *
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 /* required for IFNAMSIZ in libipq headers */
@@ -40,6 +40,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 #include <arpa/inet.h>
 #include <netinet/in.h>
 #include <netinet/ip.h>

=== modified file 'firewall/user_ipsec_api.h'
--- firewall/user_ipsec_api.h   2010-07-04 17:54:18 +0000
+++ firewall/user_ipsec_api.h   2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,13 +21,15 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This implementation provides the API for userspace IPsec.
  *
  * @brief API for the userspace IPsec functionality
  *
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #ifndef HIP_FIREWALL_USER_IPSEC_API_H

=== modified file 'firewall/user_ipsec_esp.c'
--- firewall/user_ipsec_esp.c   2010-07-06 08:46:10 +0000
+++ firewall/user_ipsec_esp.c   2010-10-15 15:29:14 +0000
@@ -1,9 +1,4 @@
-/**
- * @file
- *
- * Distributed under <a href="http://www.gnu.org/licenses/gpl2.txt";>GNU/GPL</a>
- */
-/**
+/*
  * Host Identity Protocol
  * Copyright (C) 2004-06 the Boeing Company
  *
@@ -16,14 +11,14 @@
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
+ */
+
+/**
  * @file
- *
  * @author Jeff Ahrenholz <jeffrey.m.ahrenholz@xxxxxxxxxx>
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx> (ported to HIPL project 
and major rewrite)
  *
  * @brief user-mode HIP BEET mode implementation
- *
  */
 
 #define _BSD_SOURCE

=== modified file 'firewall/user_ipsec_esp.h'
--- firewall/user_ipsec_esp.h   2010-07-04 17:54:18 +0000
+++ firewall/user_ipsec_esp.h   2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -24,27 +22,13 @@
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
  */
+
 /**
- * Host Identity Protocol
- * Copyright (C) 2004-06 the Boeing Company
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
  * @file
- *
  * @author Jeff Ahrenholz <jeffrey.m.ahrenholz@xxxxxxxxxx>
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx> (ported to HIPL project 
and major rewrite)
  *
  * @brief user-mode HIP BEET mode implementation
- *
  */
 
 #ifndef HIP_FIREWALL_USER_IPSEC_ESP_H

=== modified file 'firewall/user_ipsec_fw_msg.c'
--- firewall/user_ipsec_fw_msg.c        2010-08-19 09:32:20 +0000
+++ firewall/user_ipsec_fw_msg.c        2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * Inter-process communication with the hipd for userspace IPsec
  *
  * @brief Inter-process communication with the hipd for userspace IPsec

=== modified file 'firewall/user_ipsec_fw_msg.h'
--- firewall/user_ipsec_fw_msg.h        2010-07-04 17:54:18 +0000
+++ firewall/user_ipsec_fw_msg.h        2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * Inter-process communication with the hipd for userspace IPsec
  *
  * @brief Inter-process communication with the hipd for userspace IPsec

=== modified file 'firewall/user_ipsec_sadb.c'
--- firewall/user_ipsec_sadb.c  2010-09-03 11:40:19 +0000
+++ firewall/user_ipsec_sadb.c  2010-11-09 16:37:54 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,14 +21,16 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * Stores security association for IPsec connections and makes them
  * accessible through HITs and {dst IP, SPI}.
  *
  * @brief Security association database for IPsec connections
  *
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #include <stdint.h>
@@ -126,6 +126,12 @@
 /**
  * compares the hashes of 2 SA entries to check if they are the same
  *
+ * Note that when this function is called, the hashes of the two hash table
+ * entries provided as arguments are known to be equal.
+ * The point of this function is to allow the hash table to determine whether
+ * the entries (or rather the part used to calculate the hash) themselves are
+ * equal or whether they are different and this is just a hash collision.
+ *
  * @param sa_entry1     first SA entry to be compared with
  * @param sa_entry2     second SA entry to be compared with
  * @return              1 if different entries, else 0
@@ -133,22 +139,16 @@
 static int hip_sa_entries_cmp(const hip_sa_entry_t *sa_entry1,
                               const hip_sa_entry_t *sa_entry2)
 {
-    int err             = 0;
-    unsigned long hash1 = 0;
-    unsigned long hash2 = 0;
+    int result = 0;
 
     // values have to be present
     HIP_ASSERT(sa_entry1 && sa_entry2);
 
-    HIP_IFEL(!(hash1 = hip_sa_entry_hash(sa_entry1)), -1,
-             "failed to hash sa entry\n");
-    HIP_IFEL(!(hash2 = hip_sa_entry_hash(sa_entry2)), -1,
-             "failed to hash sa entry\n");
-
-    err = (hash1 != hash2);
-
-out_err:
-    return err;
+    result = memcmp(&sa_entry1->inner_src_addr, &sa_entry2->inner_src_addr, 
sizeof(sa_entry1->inner_src_addr));
+    if (result != 0) {
+        return result;
+    }
+    return memcmp(&sa_entry1->inner_dst_addr, &sa_entry2->inner_dst_addr, 
sizeof(sa_entry1->inner_dst_addr));
 }
 
 /**
@@ -190,6 +190,12 @@
 /**
  * compares the hashes of 2 link entries to check if they are the same
  *
+ * Note that when this function is called, the hashes of the two hash table
+ * entries provided as arguments are known to be equal.
+ * The point of this function is to allow the hash table to determine whether
+ * the entries (or rather the part used to calculate the hash) themselves are
+ * equal or whether they are different and this is just a hash collision.
+ *
  * @param link_entry1   first link entry to be compared with
  * @param link_entry2   second link entry to be compared with
  * @return              1 if different entries, else 0
@@ -197,68 +203,27 @@
 static int hip_link_entries_cmp(const hip_link_entry_t *link_entry1,
                                 const hip_link_entry_t *link_entry2)
 {
-    int err             = 0;
-    unsigned long hash1 = 0;
-    unsigned long hash2 = 0;
+    int result = 0;
 
     // values have to be present
     HIP_ASSERT(link_entry1 != NULL && link_entry1->spi != 0);
     HIP_ASSERT(link_entry2 != NULL && link_entry2->spi != 0);
 
-    HIP_IFEL(!(hash1 = hip_link_entry_hash(link_entry1)), -1,
-             "failed to hash link entry\n");
-    HIP_IFEL(!(hash2 = hip_link_entry_hash(link_entry2)), -1,
-             "failed to hash link entry\n");
-
-    err = (hash1 != hash2);
-
-out_err:
-    return err;
+    result = link_entry1->spi - link_entry2->spi;
+    if (result != 0) {
+        return result;
+    }
+    return memcmp(&link_entry1->dst_addr, &link_entry2->dst_addr, 
sizeof(link_entry1->dst_addr));
 }
 
-/**
- * callback wrappers providing per-variable casts before calling the
- * type-specific callbacks
- *
- * @param hip_sa_entry      function pointer
- * @param hip_sa_entry_t    type to be casted to
- *
- * @note appends _hash to given function
- */
-static IMPLEMENT_LHASH_HASH_FN(hip_sa_entry, hip_sa_entry_t)
-
-/**
- * callback wrappers providing per-variable casts before calling the
- * type-specific callbacks
- *
- * @param hip_sa_entries    function pointer
- * @param hip_sa_entry_t    type to be casted to
- *
- * @note appends _cmp to given function
- */
-static IMPLEMENT_LHASH_COMP_FN(hip_sa_entries, hip_sa_entry_t)
-
-/**
- * callback wrappers providing per-variable casts before calling the
- * type-specific callbacks
- *
- * @param hip_link_entry    function pointer
- * @param hip_link_entry_t  type to be casted to
- *
- * @note appends _hash to given function
- */
-static IMPLEMENT_LHASH_HASH_FN(hip_link_entry, hip_link_entry_t)
-
-/**
- * callback wrappers providing per-variable casts before calling the
- * type-specific callbacks
- *
- * @param hip_link_entries  function pointer
- * @param hip_link_entry_t  type to be casted to
- *
- * @note appends _cmp to given function
- */
-static IMPLEMENT_LHASH_COMP_FN(hip_link_entries, hip_link_entry_t)
+/*
+ * callback wrappers providing per-variable casts before calling the
+ * type-specific callbacks
+ */
+STATIC_IMPLEMENT_LHASH_HASH_FN(hip_sa_entry,   hip_sa_entry_t)
+STATIC_IMPLEMENT_LHASH_COMP_FN(hip_sa_entries, hip_sa_entry_t)
+STATIC_IMPLEMENT_LHASH_HASH_FN(hip_link_entry,   hip_link_entry_t)
+STATIC_IMPLEMENT_LHASH_COMP_FN(hip_link_entries, hip_link_entry_t)
 
 /**
  * finds a link entry in the linkdb

=== modified file 'firewall/user_ipsec_sadb.h'
--- firewall/user_ipsec_sadb.h  2010-09-03 11:40:19 +0000
+++ firewall/user_ipsec_sadb.h  2010-11-09 16:37:54 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,14 +21,16 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * Stores security association for IPsec connections and makes them
  * accessasible through HITs and (dst IP, spi).
  *
  * @brief Security association database for IPsec connections
  *
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #ifndef HIP_FIREWALL_USER_IPSEC_SADB_H

=== modified file 'hipd/accessor.c'
--- hipd/accessor.c     2010-07-07 16:42:17 +0000
+++ hipd/accessor.c     2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * @brief An assortment of access for functions for hipd
  *
  * @author Miika Komu <miika@xxxxxx>

=== modified file 'hipd/accessor.h'
--- hipd/accessor.h     2010-07-07 16:42:17 +0000
+++ hipd/accessor.h     2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'hipd/cert.c'
--- hipd/cert.c 2010-08-29 16:24:14 +0000
+++ hipd/cert.c 2010-10-19 12:08:54 +0000
@@ -1,6 +1,5 @@
-/** @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -22,6 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file
  *
  * This file defines the certificate signing and verification
  * functions to use with HIP
@@ -74,7 +77,7 @@
  */
 int hip_cert_spki_sign(struct hip_common *msg)
 {
-    int err                      = 0, sig_len = 0, algo = 0, t = 0;
+    int err = 0, sig_len = 0, algo = 0, t = 0;
     const struct hip_cert_spki_info *p_cert;
     struct hip_cert_spki_info *cert;
     struct hip_host_id *host_id  = NULL;
@@ -82,7 +85,7 @@
     unsigned char *signature_b64 = NULL;
     unsigned char *digest_b64    = NULL;
     unsigned char *sha_retval;
-    uint8_t *signature                = NULL;
+    uint8_t *signature           = NULL;
     DSA_SIG *dsa_sig             = NULL;
 
     /* RSA needed variables */
@@ -144,8 +147,8 @@
         HIP_IFEL((!signature), -1, "Malloc for signature failed\n");
         memset(signature, 0, sig_len);
 
-        err       = RSA_sign(NID_sha1, sha_digest, SHA_DIGEST_LENGTH, 
signature,
-                             (unsigned int *) &sig_len, rsa);
+        err = RSA_sign(NID_sha1, sha_digest, SHA_DIGEST_LENGTH, signature,
+                       (unsigned int *) &sig_len, rsa);
         HIP_IFEL((err = err == 0 ? -1 : 0), -1, "RSA_sign error\n");
     } else if (algo == HIP_HI_DSA) {
         p_bin        = malloc(BN_num_bytes(dsa->p) + 1);
@@ -175,8 +178,8 @@
         signature    = malloc(HIP_DSA_SIG_SIZE);
         memset(signature, 0, HIP_DSA_SIG_SIZE);
 
-        t            = BN_num_bytes(dsa->p);
-        t            = (t - 64) / 8;
+        t = BN_num_bytes(dsa->p);
+        t = (t - 64) / 8;
         HIP_IFEL(t > 8, 1, "Illegal DSA key\n");
 
         signature[0] = t;
@@ -191,11 +194,11 @@
     /* clearing signature field just to be sure */
     memset(cert->signature, '\0', sizeof(cert->signature));
 
-    HIP_IFEL(!(digest_b64 = (unsigned char *) base64_encode((unsigned char *) 
sha_digest,
-                                                            (unsigned int) 
sizeof(sha_digest))),
+    HIP_IFEL(EVP_EncodeBlock(digest_b64, (unsigned char *) sha_digest,
+                             (unsigned int) sizeof(sha_digest)) > 0,
              -1, "Failed to encode digest_b64\n");
-    HIP_IFEL(!(signature_b64 = (unsigned char *) base64_encode((unsigned char 
*) signature,
-                                                               (unsigned int) 
sig_len)),
+    HIP_IFEL(EVP_EncodeBlock(signature_b64, (unsigned char *) signature,
+                             (unsigned int) sig_len) > 0,
              -1, "Failed to encode signature_b64\n");
     /* create (signature (hash sha1 |digest|)|signature|) */
     sprintf(cert->signature, "(signature (hash sha1 |%s|)|%s|)",
@@ -215,7 +218,7 @@
                  -1,
                  "Error in converting public exponent from BN to bin\n");
 
-        HIP_IFEL(!(n_b64 = (unsigned char *) base64_encode((unsigned char *) 
n_bin, RSA_size(rsa))),
+        HIP_IFEL(EVP_EncodeBlock(n_b64, (unsigned char *) n_bin, 
RSA_size(rsa)) > 0,
                  -1,
                  "Failed to encode n_b64\n");
 
@@ -241,32 +244,29 @@
          */
         HIP_IFEL(!(BN_bn2bin(dsa->p, p_bin)), -1,
                  "Error in converting public exponent from BN to bin\n");
-        HIP_IFEL(!(p_b64 = (unsigned char *) base64_encode((unsigned char *) 
p_bin,
-                                                           
BN_num_bytes(dsa->p))),
+        HIP_IFEL(EVP_EncodeBlock(p_b64, (unsigned char *) p_bin, 
BN_num_bytes(dsa->p)) > 0,
                  -1, "Failed to encode p_b64\n");
 
         HIP_IFEL(!(BN_bn2bin(dsa->q, q_bin)), -1,
                  "Error in converting public exponent from BN to bin\n");
-        HIP_IFEL(!(q_b64 = (unsigned char *) base64_encode((unsigned char *) 
q_bin,
-                                                           
BN_num_bytes(dsa->q))),
+        HIP_IFEL(EVP_EncodeBlock(q_b64, (unsigned char *) q_bin, 
BN_num_bytes(dsa->q)) > 0,
                  -1, "Failed to encode q_64");
 
         HIP_IFEL(!(BN_bn2bin(dsa->g, g_bin)), -1,
                  "Error in converting public exponent from BN to bin\n");
-        HIP_IFEL(!(g_b64 = (unsigned char *) base64_encode((unsigned char *) 
g_bin,
-                                                           
BN_num_bytes(dsa->g))),
+        HIP_IFEL(EVP_EncodeBlock(g_b64, (unsigned char *) g_bin, 
BN_num_bytes(dsa->g)) > 0,
                  -1, "Failed to encode g_b64\n");
 
         HIP_IFEL(!(BN_bn2bin(dsa->pub_key, y_bin)), -1,
                  "Error in converting public exponent from BN to bin\n");
-        HIP_IFEL(!(y_b64 = (unsigned char *) base64_encode((unsigned char *) 
y_bin,
-                                                           
BN_num_bytes(dsa->pub_key))),
+        HIP_IFEL(EVP_EncodeBlock(y_b64, (unsigned char *) y_bin, 
BN_num_bytes(dsa->pub_key)) > 0,
                  -1, "Failed to encode y_b64\n");
 
         sprintf(cert->public_key, "(public_key (dsa-pkcs1-sha1 (p |%s|)(q 
|%s|)"
                                   "(g |%s|)(y |%s|)))",
                 p_b64, q_b64, g_b64, y_b64);
-    } else {HIP_IFEL(1 == 0, -1, "Unknown algorithm for public-key element\n");
+    } else {
+        HIP_IFEL(1 == 0, -1, "Unknown algorithm for public-key element\n");
     }
 
     /* Put the results into the msg back */
@@ -486,7 +486,8 @@
                  "Failed to run hip_cert_regex (exponent)\n");
         e_hex = malloc(stop - start);
         HIP_IFEL((!e_hex), -1, "Malloc for e_hex failed\n");
-        snprintf(e_hex, (stop - start - 1), "%s", (char *) 
&cert->public_key[start + 1]);
+        snprintf(e_hex, (stop - start - 1), "%s",
+                 (char *) &cert->public_key[start + 1]);
 
         /* public modulus */
         start       = stop = 0;
@@ -498,7 +499,8 @@
         modulus     = malloc(stop - start + 1);
         HIP_IFEL((!modulus), -1, "Malloc for modulus failed\n");
         memset(modulus, 0, (stop - start + 1));
-        snprintf((char *) modulus_b64, (stop - start - 1), "%s", (char *) 
&cert->public_key[start + 1]);
+        snprintf((char *) modulus_b64, (stop - start - 1), "%s",
+                 (char *) &cert->public_key[start + 1]);
 
         /* put the stuff into the RSA struct */
         BN_hex2bn(&rsa->e, e_hex);
@@ -531,7 +533,8 @@
         p_bin = malloc(stop - start + 1);
         HIP_IFEL((!p_bin), -1, "Malloc for p_bin failed\n");
         memset(p_bin, 0, (stop - start + 1));
-        snprintf((char *) p_b64, (stop - start - 1), "%s", (char *) 
&cert->public_key[start + 1]);
+        snprintf((char *) p_b64, (stop - start - 1), "%s",
+                 (char *) &cert->public_key[start + 1]);
         evpret = EVP_DecodeBlock(p_bin, p_b64, strlen((char *) p_b64));
 
         /* dsa->q */
@@ -544,7 +547,8 @@
         q_bin  = malloc(stop - start + 1);
         HIP_IFEL((!q_bin), -1, "Malloc for q_bin failed\n");
         memset(q_bin, 0, (stop - start + 1));
-        snprintf((char *) q_b64, (stop - start - 1), "%s", (char *) 
&cert->public_key[start + 1]);
+        snprintf((char *) q_b64, (stop - start - 1), "%s",
+                 (char *) &cert->public_key[start + 1]);
         evpret = EVP_DecodeBlock(q_bin, q_b64, strlen((char *) q_b64));
 
         /* dsa->g */
@@ -557,7 +561,8 @@
         g_bin  = malloc(stop - start + 1);
         HIP_IFEL((!g_bin), -1, "Malloc for g_bin failed\n");
         memset(g_bin, 0, (stop - start + 1));
-        snprintf((char *) g_b64, (stop - start - 1), "%s", (char *) 
&cert->public_key[start + 1]);
+        snprintf((char *) g_b64, (stop - start - 1), "%s",
+                 (char *) &cert->public_key[start + 1]);
         evpret = EVP_DecodeBlock(g_bin, g_b64, strlen((char *) g_b64));
 
         /* dsa->y */
@@ -570,7 +575,8 @@
         y_bin  = malloc(stop - start + 1);
         HIP_IFEL((!y_bin), -1, "Malloc for y_bin failed\n");
         memset(y_bin, 0, (stop - start + 1));
-        snprintf((char *) y_b64, (stop - start - 1), "%s", (char *) 
&cert->public_key[start + 1]);
+        snprintf((char *) y_b64, (stop - start - 1), "%s",
+                 (char *) &cert->public_key[start + 1]);
         evpret = EVP_DecodeBlock(y_bin, y_b64, strlen((char *) y_b64));
     } else {
         HIP_IFEL((1 == 0), -1, "Unknown algorithm\n");
@@ -606,7 +612,8 @@
     signature_b64 = malloc(stop - start + 1);
     HIP_IFEL((!signature_b64), -1, "Failed to malloc signature_b64\n");
     memset(signature_b64, '\0', keylen);
-    snprintf((char *) signature_b64, (stop - start - 2), "%s", (char *) 
&cert->signature[start + 2]);
+    snprintf((char *) signature_b64, (stop - start - 2), "%s",
+             (char *) &cert->signature[start + 2]);
     if (algo == HIP_HI_DSA) {
         signature = malloc(stop - start + 1);
         HIP_IFEL(!signature, -1, "Failed to malloc signature (dsa)\n");

=== modified file 'hipd/cert.h'
--- hipd/cert.h 2010-07-07 16:42:17 +0000
+++ hipd/cert.h 2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -25,20 +23,19 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
-#ifndef HIP_HIPD_CERT_H
-#define HIP_HIPD_CERT_H
-
-/** @file
- * A header file for cert.c
+/**
+ * @file
  *
  * Certificate signing and verification functions.
  *
  * @author Samu Varjonen
  * @version 0.1
  * @date 31.3.2008
- *
  */
 
+#ifndef HIP_HIPD_CERT_H
+#define HIP_HIPD_CERT_H
+
 #include <openssl/rsa.h>
 
 #include "lib/core/hashtable.h"

=== modified file 'hipd/close.c'
--- hipd/close.c        2010-08-29 16:24:14 +0000
+++ hipd/close.c        2010-10-22 10:38:11 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,9 +21,11 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * @brief Processing for CLOSE control packets
- *
  * @author Miika Komu <miika@xxxxxx>
  */
 
@@ -71,7 +71,7 @@
 {
     int err                      = 0, mask = 0;
     int delete_ha_info           = *(int *) ((uint8_t *)opaque + 
sizeof(hip_hit_t));
-    hip_hit_t *peer              = (hip_hit_t *) opaque;
+    hip_hit_t *peer              = opaque;
     struct hip_common *msg_close = NULL;
 
 #ifdef CONFIG_HIP_PERFORMANCE
@@ -306,17 +306,16 @@
     int err = 0, echo_len;
     const struct hip_echo_request *request;
 
-    HIP_IFE(!(ctx->output_msg = hip_msg_alloc()), -ENOMEM);
-
     HIP_IFEL(!(request =
                  hip_get_param(ctx->input_msg, HIP_PARAM_ECHO_REQUEST_SIGN)),
              -1, "No echo request under signature.\n");
 
     echo_len = hip_get_param_contents_len(request);
 
+    hip_msg_init(ctx->output_msg);
     hip_build_network_hdr(ctx->output_msg,
                         HIP_CLOSE_ACK,
-                        0,
+                        HIP_PACKET_CTRL_NON,
                         &(ctx->hadb_entry)->hit_our,
                         &(ctx->hadb_entry)->hit_peer);
 
@@ -394,9 +393,6 @@
              -1,
              "Deleting peer info failed.\n");
 out_err:
-    if (ctx->output_msg) {
-        free(ctx->output_msg);
-    }
 #ifdef CONFIG_HIP_PERFORMANCE
     HIP_DEBUG("Stop and write PERF_HANDLE_CLOSE\n");
     hip_perf_stop_benchmark( perf_set, PERF_HANDLE_CLOSE );
@@ -434,7 +430,7 @@
     HIP_IFEL(ipv6_addr_any(&ctx->input_msg->hitr), -1,
             "Received NULL receiver HIT in CLOSE ACK. Dropping\n");
 
-    if (!hip_controls_sane(ntohs(ctx->input_msg->control), 0)) {
+    if (!hip_controls_sane(ntohs(ctx->input_msg->control), 
HIP_PACKET_CTRL_NON)) {
         HIP_ERROR("Received illegal controls in CLOSE ACK: 0x%x. Dropping\n",
                 ntohs(ctx->input_msg->control));
         goto out_err;

=== modified file 'hipd/close.h'
--- hipd/close.h        2010-07-07 16:42:17 +0000
+++ hipd/close.h        2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'hipd/configfilereader.c'
--- hipd/configfilereader.c     2010-09-03 11:40:19 +0000
+++ hipd/configfilereader.c     2010-11-09 16:37:54 +0000
@@ -1,8 +1,5 @@
-/** @file
- * This file defines an all-round configurationfilereader.
- *
- * @author  Lauri Silvennoinen
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -24,6 +21,13 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file
+ * This file defines an all-round configurationfilereader.
+ *
+ * @author  Lauri Silvennoinen
  * @see     configfilereader.h for usage instructions.
  */
 

=== modified file 'hipd/configfilereader.h'
--- hipd/configfilereader.h     2010-07-07 16:42:17 +0000
+++ hipd/configfilereader.h     2010-10-15 15:29:14 +0000
@@ -1,5 +1,29 @@
-/** @file
- * A header file for configfilereader.c
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE O
+ */
+
+/**
+ * @file
  *
  * This is a general purpose configurationfilereader. The configurationfile
  * consists of stanzas of the following form:
@@ -24,7 +48,7 @@
  * <li>Declare a linked list <code>hip_configvaluelist_t values</code> for 
values</li>
  * <li>Open the configfile using <code>fopen()</code></li>
  * <li>Go through the configuration file using hip_cf_get_line_data()
- * inside a <code>do{ }while()</code> -loop:
+ * inside a <code>do { } while ()</code> -loop:
  * <pre>
  * do {
  *     parseerr = 0;
@@ -32,19 +56,19 @@
  *     hip_cvl_init(&values);
  *     lineerr = hip_cf_get_line_data(fp, parameter, &values, &parseerr);
  *
- *     if(parseerr == 0){
+ *     if (parseerr == 0) {
  *
  *       ... parameter has now the parameter name ...
  *
- *        hip_configfilevalue_t *current = NULL;
- *    while((current = hip_cvl_get_next(&values, current)) != NULL) {
+ *         hip_configfilevalue_t *current = NULL;
+ *         while ((current = hip_cvl_get_next(&values, current)) != NULL) {
  *
  *           ... do stuff with the current value ...
  *
- *        }
- *    }
- *    hip_cvl_uninit(&values);
- * } while(lineerr != EOF);
+ *         }
+ *     }
+ *     hip_cvl_uninit(&values);
+ * } while (lineerr != EOF);
  * </pre>
  * </li>
  * <li>Close the configfile using <code>close()</code></li>
@@ -53,28 +77,6 @@
  * @author  Lauri Silvennoinen
  * @version 1.0
  * @date    14.02.2008
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use,
- * copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following
- * conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
  */
 
 #ifndef HIP_HIPD_CONFIGFILEREADER_H

=== modified file 'hipd/cookie.c'
--- hipd/cookie.c       2010-08-19 09:32:20 +0000
+++ hipd/cookie.c       2010-10-15 15:29:14 +0000
@@ -1,8 +1,5 @@
-/**
- * @file
- * HIP cookie handling
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -24,10 +21,14 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file
+ * HIP cookie handling
  *
  * @author Kristian Slavov <ksl#iki.fi>
  * @author Miika Komu <miika#iki.fi>
- *
  */
 
 #define _BSD_SOURCE

=== modified file 'hipd/cookie.h'
--- hipd/cookie.h       2010-08-19 09:32:20 +0000
+++ hipd/cookie.h       2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'hipd/dh.c'
--- hipd/dh.c   2010-07-07 16:42:17 +0000
+++ hipd/dh.c   2010-11-01 13:13:35 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * @brief Diffie-Hellman wrappers for HIP
  *
  * @author Mika Kousa <mkousa@xxxxxx>
@@ -39,6 +40,15 @@
 #include "lib/core/debug.h"
 #include "dh.h"
 
+/**
+ * This table holds Diffie-Hellman values used during HIP BEXs.
+ * These values are generated when the HIP daemon starts and valid for its
+ * lifetime.
+ * Each array element corresponds to a DH value of a specific DH group.
+ * The valid groups are defined in RFC 5201, section 5.2.6.
+ * This array is indexed by the Group ID value defined in the RFC.
+ * Note that this means that the array element at index 0 is thus unused.
+ */
 DH *dh_table[HIP_MAX_DH_GROUP_ID] = {0};
 
 /**
@@ -52,6 +62,12 @@
     int res;
     DH *tmp;
 
+    if (group_id <= 0 || group_id >= HIP_MAX_DH_GROUP_ID) {
+        HIP_ERROR("The Group ID %d is invalid\n", group_id);
+        res = -1;
+        goto err_free;
+    }
+
     /*
      * First check that we have the key available.
      * Then encode it into the buffer
@@ -104,6 +120,11 @@
     int err = 0;
     DH *tmp;
 
+    if (group_id <= 0 || group_id >= HIP_MAX_DH_GROUP_ID) {
+        HIP_ERROR("The Group ID %d is invalid\n", group_id);
+        return -1;
+    }
+
     /*
      * First check that we have the key available.
      * Then encode it into the buffer
@@ -145,7 +166,7 @@
     maxmask  = (1 << (HIP_MAX_DH_GROUP_ID + 1)) - 1;
     bitmask &= maxmask;
 
-    for (i = 1; i <= HIP_MAX_DH_GROUP_ID; i++) {
+    for (i = 1; i < HIP_MAX_DH_GROUP_ID; i++) {
         if (bitmask & (1 << i)) {
             tmp = hip_generate_dh_key(i);
             if (!tmp) {

=== modified file 'hipd/dh.h'
--- hipd/dh.h   2010-07-07 16:42:17 +0000
+++ hipd/dh.h   2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'hipd/hadb.c'
--- hipd/hadb.c 2010-09-08 16:12:15 +0000
+++ hipd/hadb.c 2010-11-09 16:37:54 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * Host Association Database (HADB) is the heart of the hipd and it
  * contains state information about HIP connectivity with remote
  * hosts. It shouldn't be confused with Host Identity Data Base (HIDB)
@@ -140,28 +141,39 @@
 }
 
 /** A callback wrapper of the prototype required by @c lh_new(). */
-static IMPLEMENT_LHASH_HASH_FN(hip_ha, hip_ha_t)
+STATIC_IMPLEMENT_LHASH_HASH_FN(hip_ha, hip_ha_t)
 
 /**
  * a comparison function for the hash table algorithm to distinguish
  * two HAs from each other
  *
+ * Note that when this function is called, the hashes of the two hash table
+ * entries provided as arguments are known to be equal.
+ * The point of this function is to allow the hash table to determine whether
+ * the entries (or rather the part used to calculate the hash) themselves are
+ * equal or whether they are different and this is just a hash collision.
+ *
  * @param ha1 a HA to compare for equality
  * @param ha2 a HA to compare for equality
  * @return zero if the HAs match or non-zero otherwise
  */
 static int hip_ha_cmp(const hip_ha_t *ha1, const hip_ha_t *ha2)
 {
-    if (ha1 == NULL || &(ha1->hit_our) == NULL || &(ha1->hit_peer) == NULL ||
-        ha2 == NULL || &(ha2->hit_our) == NULL || &(ha2->hit_peer) == NULL) {
+    int result_hit_our = 0;
+
+    if (ha1 == NULL || ha2 == NULL) {
         return 1;
     }
 
-    return hip_ha_LHASH_HASH(ha1) != hip_ha_LHASH_HASH(ha2);
+    result_hit_our = memcmp(&ha1->hit_our, &ha2->hit_our, 
sizeof(ha1->hit_our));
+    if (result_hit_our != 0) {
+        return result_hit_our;
+    }
+    return memcmp(&ha1->hit_peer, &ha2->hit_peer, sizeof(ha1->hit_peer));
 }
 
 /** A callback wrapper of the prototype required by @c lh_new(). */
-static IMPLEMENT_LHASH_COMP_FN(hip_ha, hip_ha_t)
+STATIC_IMPLEMENT_LHASH_COMP_FN(hip_ha, hip_ha_t)
 
 /**
  * build a digest of a peer address
@@ -181,7 +193,13 @@
 }
 
 /**
- * test if two peer addresses match
+ * test if two peer addresses match to detect and avoid hash collisions in the 
peer address list.
+ *
+ * Note that when this function is called, the hashes of the two hash table
+ * entries provided as arguments are known to be equal.
+ * The point of this function is to allow the hash table to determine whether
+ * the entries (or rather the part used to calculate the hash) themselves are
+ * equal or whether they are different and this is just a hash collision.
  *
  * @param ptr1 a pointer to a hip_peer_addr_list_item
  * @param ptr2 a pointer to a hip_peer_addr_list_item
@@ -189,7 +207,9 @@
  */
 static int hip_match_peer_addr(const void *ptr1, const void *ptr2)
 {
-    return hip_hash_peer_addr(ptr1) != hip_hash_peer_addr(ptr2);
+    const struct in6_addr *addr1 = &((const struct hip_peer_addr_list_item *) 
ptr1)->address;
+    const struct in6_addr *addr2 = &((const struct hip_peer_addr_list_item *) 
ptr2)->address;
+    return memcmp(addr1, addr2, sizeof(*addr1));
 }
 
 /* PRIMITIVES */
@@ -1063,11 +1083,6 @@
  */
 void hip_init_hadb(void)
 {
-    /* The next line initializes the hash table for host associations. Note
-     * that we are using callback wrappers IMPLEMENT_LHASH_HASH_FN and
-     * IMPLEMENT_LHASH_COMP_FN defined in the beginning of this file. These
-     * provide automagic variable casts, so that all elements stored in the
-     * hash table are cast to hip_ha_t. Lauri 09.10.2007 16:58. */
     hadb_hit = hip_ht_init(LHASH_HASH_FN(hip_ha), LHASH_COMP_FN(hip_ha));
 }
 
@@ -1153,7 +1168,7 @@
 }
 
 /** A callback wrapper of the prototype required by @c lh_doall_arg(). */
-static IMPLEMENT_LHASH_DOALL_FN(hip_hadb_rec_free, hip_ha_t)
+STATIC_IMPLEMENT_LHASH_DOALL_FN(hip_hadb_rec_free, hip_ha_t)
 
 /**
  * Uninitialize host association database
@@ -1325,7 +1340,6 @@
  *                   IPv4 address  used as searching key.
  * @return           a pointer to a matching host association or NULL if
  *                   a matching host association was not found.
- * @author           Miika Komu
  */
 hip_ha_t *hip_hadb_find_rvs_candidate_entry(const hip_hit_t *local_hit,
                                             const hip_hit_t *rvs_ip)
@@ -1422,10 +1436,10 @@
 {
     struct in_addr lsi_prefix;
     uint8_t hostname[HOST_NAME_MAX];
-    int index = 1;
+    int idx = 1;
 
     do {
-        lsi_prefix.s_addr = htonl(HIP_LSI_PREFIX | index++);
+        lsi_prefix.s_addr = htonl(HIP_LSI_PREFIX | idx++);
     } while (lsi_assigned(lsi_prefix) ||
              !hip_map_lsi_to_hostname_from_hosts(lsi, (char *) hostname));
 

=== modified file 'hipd/hadb.h'
--- hipd/hadb.h 2010-08-25 12:53:17 +0000
+++ hipd/hadb.h 2010-11-09 16:37:54 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'hipd/hadb_legacy.c'
--- hipd/hadb_legacy.c  2010-07-07 16:42:17 +0000
+++ hipd/hadb_legacy.c  2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This file contains legacy functions for mobility that should be rewritten 
for modularity.
  * They are still included in the code base due to locator dependencies with
  * base exchange code. See bugzilla ids 592195 and 592196.

=== modified file 'hipd/hadb_legacy.h'
--- hipd/hadb_legacy.h  2010-07-07 16:42:17 +0000
+++ hipd/hadb_legacy.h  2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'hipd/hidb.c'
--- hipd/hidb.c 2010-08-19 09:32:20 +0000
+++ hipd/hidb.c 2010-10-19 12:08:54 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * @brief A database to local Host Identifiers and the related accessor 
functions.
  *
  * @author Janne Lundberg <jlu#tcs.hut.fi>
@@ -187,13 +188,21 @@
 /**
  * matching function required by hashtable/linked list implementation
  *
+ * Note that when this function is called, the hashes of the two hash table
+ * entries provided as arguments are known to be equal.
+ * The point of this function is to allow the hash table to determine whether
+ * the entries (or rather the part used to calculate the hash) themselves are
+ * equal or whether they are different and this is just a hash collision.
+ *
  * @param ptr1 a pointer to hip_host_id_entry
  * @param ptr2 a pointer to hip_host_id_entry
  * @return zero on match or non-zero on unmatch
  */
 int hip_hidb_match(const void *ptr1, const void *ptr2)
 {
-    return hip_hidb_hash(ptr1) != hip_hidb_hash(ptr2);
+    const hip_hit_t *hit1 = &((const struct hip_host_id_entry *) 
ptr1)->lhi.hit;
+    const hip_hit_t *hit2 = &((const struct hip_host_id_entry *) 
ptr2)->lhi.hit;
+    return memcmp(hit1, hit2, sizeof(*hit1));
 }
 
 /**
@@ -346,7 +355,7 @@
 
     list_for_each(item, hip_local_hostid_db, c) {
         id_entry = (struct hip_host_id_entry *) list_entry(item);
-        if (hip_hit_are_equal(&id_entry->lhi.hit, our)) {
+        if (memcmp(&id_entry->lhi.hit, our, sizeof(*our)) == 0) {
             memcpy(our_lsi, &id_entry->lsi, sizeof(hip_lsi_t));
             return 0;
         }

=== modified file 'hipd/hidb.h'
--- hipd/hidb.h 2010-07-07 16:42:17 +0000
+++ hipd/hidb.h 2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'hipd/hip_socket.c'
--- hipd/hip_socket.c   2010-08-29 16:24:14 +0000
+++ hipd/hip_socket.c   2010-10-15 15:29:14 +0000
@@ -1,8 +1,5 @@
-/** @file
- * This file defines handling functions for network sockets for the Host
- * Identity Protocol (HIP).
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -24,6 +21,12 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file
+ * This file defines handling functions for network sockets for the Host
+ * Identity Protocol (HIP).
  *
  * @author  Tim Just
  */
@@ -250,6 +253,18 @@
     }
 }
 
+/**
+ * Run callbacks for any global socket that's flagged in the fd_set.
+ * Invoked from hipd_main's main loop.
+ *
+ * @param read_fdset fd_set loaded with global socket handles, after
+ *                   select() call.
+ * @param ctx        Initialized packet context. Will be prepared for next
+ *                   iteration upon return.
+ * @todo             select() should probably be called here rather than in
+ *                   hipd_main (passing read_fdset is superfluous)
+ * @see              hipd_main
+ */
 void hip_run_socket_handles(fd_set *read_fdset, struct hip_packet_context *ctx)
 {
     hip_ll_node_t *iter = NULL;
@@ -260,8 +275,13 @@
             socketfd = ((struct socketfd*) iter->ptr)->fd;
 
             if (FD_ISSET(socketfd, read_fdset)) {
-                ctx->error = 0;
                 ((struct socketfd*) iter->ptr)->func_ptr(ctx);
+                HIP_DEBUG("result: %d\n", ctx->error);
+
+                /* Reset for next iteration.
+                 * msg_ports has no reset-state. */
+                ctx->hadb_entry = NULL;
+                ctx->error      = 0;
             }
         }
     } else {

=== modified file 'hipd/hip_socket.h'
--- hipd/hip_socket.h   2010-07-04 17:54:18 +0000
+++ hipd/hip_socket.h   2010-10-15 15:29:14 +0000
@@ -1,8 +1,5 @@
-/**
- * @file
- * The header file for hipd/hip_socket.c
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -24,10 +21,13 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * @author Tim Just
- *
  */
+
 #ifndef HIP_HIPD_SOCKET_H
 #define HIP_HIPD_SOCKET_H
 

=== modified file 'hipd/hipd.c'
--- hipd/hipd.c 2010-09-03 11:56:17 +0000
+++ hipd/hipd.c 2010-11-09 16:37:54 +0000
@@ -1,8 +1,5 @@
-/** @file
- * The HIPL main file containing the daemon main loop.
- *
- * @date 28.01.2008
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -24,6 +21,13 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file
+ * The HIPL main file containing the daemon main loop.
+ *
+ * @date 28.01.2008
  * @note HIPU: libm.a is not availble on OS X. The functions are present in 
libSystem.dyld, though
  * @note HIPU: lcap is used by HIPD. It needs to be changed to generic posix 
functions.
  */
@@ -128,9 +132,6 @@
 /* Tells to the daemon should it build LOCATOR parameters to R1 and I2 */
 int hip_locator_status             = HIP_MSG_SET_LOCATOR_OFF;
 
-/* Create /etc/hip stuff and exit (used for binary hipfw packaging) */
-int create_configs_and_exit        = 0;
-
 /* We are caching the IP addresses of the host here. The reason is that during
  * in hip_handle_acquire it is not possible to call getifaddrs (it creates
  * a new netlink socket and seems like only one can be open per process).
@@ -282,8 +283,6 @@
     fd_set read_fdset;
     struct hip_packet_context ctx;
 
-    memset(&ctx, 0, sizeof(ctx));
-
 #ifdef CONFIG_HIP_PERFORMANCE
     HIP_DEBUG("Creating perf set\n");
     perf_set = hip_perf_create(PERF_MAX);
@@ -339,6 +338,11 @@
     HIP_INFO("hipd pid=%d starting\n", getpid());
     time(&load_time);
 
+    /* prepare the one and only hip_packet_context instance */
+    memset(&ctx, 0, sizeof(ctx));
+    HIP_IFEL(!(ctx.input_msg  = hip_msg_alloc()), ENOMEM, "Insufficient 
memory");
+    HIP_IFEL(!(ctx.output_msg = hip_msg_alloc()), ENOMEM, "Insufficient 
memory");
+
     /* Default initialization function. */
     HIP_IFEL(hipd_init(flags), 1, "hipd_init() failed!\n");
 
@@ -349,15 +353,6 @@
 
     highest_descriptor = hip_get_highest_descriptor();
 
-    /* Allocate user message. */
-    HIP_IFE(!(ctx.input_msg = hip_msg_alloc()), 1);
-    ctx.output_msg  = NULL;
-    ctx.src_addr    = malloc(sizeof(struct in6_addr));
-    ctx.dst_addr    = malloc(sizeof(struct in6_addr));
-    ctx.msg_ports   = malloc(sizeof(struct hip_stateless_info));
-    ctx.hadb_entry  = NULL;
-    ctx.error = 0;
-
     /* Enter to the select-loop */
     HIP_DEBUG_GL(HIP_DEBUG_GROUP_INIT,
                  HIP_DEBUG_LEVEL_INFORMATIVE,
@@ -427,17 +422,8 @@
     if (ctx.input_msg) {
         free(ctx.input_msg);
     }
-
-    if (ctx.src_addr) {
-        free(ctx.src_addr);
-    }
-
-    if (ctx.dst_addr) {
-        free(ctx.dst_addr);
-    }
-
-    if (ctx.msg_ports) {
-        free(ctx.msg_ports);
+    if (ctx.output_msg) {
+        free(ctx.output_msg);
     }
 
     HIP_INFO("hipd pid=%d exiting, retval=%d\n", getpid(), err);

=== modified file 'hipd/hipd.h'
--- hipd/hipd.h 2010-09-03 11:40:19 +0000
+++ hipd/hipd.h 2010-11-09 16:37:54 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'hipd/hiprelay.c'
--- hipd/hiprelay.c     2010-08-29 16:24:14 +0000
+++ hipd/hiprelay.c     2010-10-20 03:38:26 +0000
@@ -1,6 +1,5 @@
-/** @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -22,11 +21,14 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This file defines the rendezvous extension and the UDP relay for HIP packets
  * for the Host Identity Protocol (HIP). See header file for usage
  * instructions. Supports access control in the form in white lists in
- * the /etc/hip/relay_config file.
+ * the HIPL_SYSCONFDIR/relay_config file.
  *
  * The HIP relay combines the functionalites of an rendezvous server (RVS) and
  * a HIP UDP relay. The HIP relay consists of a hashtable for storing IP 
address
@@ -89,7 +91,7 @@
  * @note    Related draft:
  *          <a 
href="http://www.ietf.org/internet-drafts/draft-ietf-hip-nat-traversal-03.txt";>
  *          draft-ietf-hip-nat-traversal-03</a>
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -269,7 +271,8 @@
 }
 
 /** A callback wrapper of the prototype required by @c lh_doall_arg(). */
-static IMPLEMENT_LHASH_DOALL_ARG_FN(hip_relht_rec_free_type, hip_relrec_t, 
hip_relrec_type_t)
+STATIC_IMPLEMENT_LHASH_DOALL_ARG_FN(hip_relht_rec_free_type,
+                                    hip_relrec_t, hip_relrec_type_t)
 
 /**
  * Returns relay status.
@@ -309,27 +312,32 @@
 }
 
 /** A callback wrapper of the prototype required by @c lh_new(). */
-static IMPLEMENT_LHASH_HASH_FN(hip_relht, const hip_relrec_t)
+STATIC_IMPLEMENT_LHASH_HASH_FN(hip_relht, const hip_relrec_t)
 
 /**
  * relay hash table comparison function
  *
+ * Note that when this function is called, the hashes of the two hash table
+ * entries provided as arguments are known to be equal.
+ * The point of this function is to allow the hash table to determine whether
+ * the entries (or rather the part used to calculate the hash) themselves are
+ * equal or whether they are different and this is just a hash collision.
+ *
  * @param rec1 a hip_relrec_t structure
  * @param rec2 a hip_relrec_t structure
  * @return zero if the structures are equal or one otherwise
  */
 static int hip_relht_cmp(const hip_relrec_t *rec1, const hip_relrec_t *rec2)
 {
-    if (rec1 == NULL || &(rec1->hit_r) == NULL ||
-        rec2 == NULL || &(rec2->hit_r) == NULL) {
+    if (rec1 == NULL || rec2 == NULL) {
         return 1;
     }
 
-    return hip_relht_hash(rec1) != hip_relht_hash(rec2);
+    return memcmp(&rec1->hit_r, &rec2->hit_r, sizeof(rec1->hit_r));
 }
 
 /** A callback wrapper of the prototype required by @c lh_new(). */
-static IMPLEMENT_LHASH_COMP_FN(hip_relht, const hip_relrec_t)
+STATIC_IMPLEMENT_LHASH_COMP_FN(hip_relht, const hip_relrec_t)
 
 /**
  * Puts a relay record into the hashtable. Puts the relay record pointed by
@@ -425,7 +433,7 @@
 }
 
 /** A callback wrapper of the prototype required by @c lh_doall(). */
-static IMPLEMENT_LHASH_DOALL_FN(hip_relht_rec_free, hip_relrec_t)
+STATIC_IMPLEMENT_LHASH_DOALL_FN(hip_relht_rec_free, hip_relrec_t)
 
 /**
  * Deletes a single entry from the relay record hashtable and frees the memory
@@ -451,7 +459,7 @@
 }
 
 /** A callback wrapper of the prototype required by @c lh_doall(). */
-static IMPLEMENT_LHASH_DOALL_FN(hip_relht_rec_free_expired, hip_relrec_t)
+STATIC_IMPLEMENT_LHASH_DOALL_FN(hip_relht_rec_free_expired, hip_relrec_t)
 
 /**
  * Returns the number of relay records in the hashtable @c hiprelay_ht.
@@ -533,6 +541,7 @@
  * @param hit_r    a pointer to Responder (relay client) HIT.
  * @param ip_r     a pointer to Responder (relay client) IP address.
  * @param port     responder's UDP port.
+ * @param hmac     HMAC to copy into the new record
  * @return         a pointer to a new relay record, or NULL if failed to
  *                 allocate.
  * @note           All records to be put in the hashtable should be created 
with
@@ -582,11 +591,16 @@
 }
 
 /** A callback wrapper of the prototype required by @c lh_new(). */
-static IMPLEMENT_LHASH_HASH_FN(hip_relwl, const hip_hit_t)
+STATIC_IMPLEMENT_LHASH_HASH_FN(hip_relwl, const hip_hit_t)
 
 /**
- * The compare function of the @c hiprelay_wl hashtable. Compares the hash
- * values calculated from parameter @c hit1 and @c hit2.
+ * The compare function of the @c hiprelay_wl hashtable.
+ *
+ * Note that when this function is called, the hashes of the two hash table
+ * entries provided as arguments are known to be equal.
+ * The point of this function is to allow the hash table to determine whether
+ * the entries (or rather the part used to calculate the hash) themselves are
+ * equal or whether they are different and this is just a hash collision.
  *
  * @param hit1 a pointer to a HIT.
  * @param hit2 a pointer to a HIT.
@@ -598,11 +612,11 @@
         return 1;
     }
 
-    return hip_relwl_hash(hit1) != hip_relwl_hash(hit2);
+    return memcmp(hit1, hit2, sizeof(*hit1));
 }
 
 /** A callback wrapper of the prototype required by @c lh_new(). */
-static IMPLEMENT_LHASH_COMP_FN(hip_relwl, const hip_hit_t)
+STATIC_IMPLEMENT_LHASH_COMP_FN(hip_relwl, const hip_hit_t)
 
 /**
  * Deletes a single entry from the whitelist hashtable and frees the memory
@@ -701,7 +715,7 @@
 #endif /* CONFIG_HIP_DEBUG */
 
 /** A callback wrapper of the prototype required by @c lh_doall(). */
-static IMPLEMENT_LHASH_DOALL_FN(hip_relwl_hit_free, hip_hit_t)
+STATIC_IMPLEMENT_LHASH_DOALL_FN(hip_relwl_hit_free, hip_hit_t)
 
 /**
  * Returns the whitelist status.
@@ -891,20 +905,20 @@
                       hip_relrec_t *rec,
                       const uint8_t type_hdr)
 {
-    hip_common_t *msg_to_be_relayed       = NULL;
-    const hip_tlv_common_t *current_param = NULL;
-    int err                               = 0, from_added = 0;
-    hip_tlv_type_t param_type             = 0;
+    hip_common_t *msg_to_be_relayed            = NULL;
+    const struct hip_tlv_common *current_param = NULL;
+    int err                                    = 0, from_added = 0;
+    hip_tlv_type_t param_type                  = 0;
 
     HIP_DEBUG("Msg type :      %s (%d)\n",
               hip_message_type_name(hip_get_msg_type(ctx->input_msg)),
               hip_get_msg_type(ctx->input_msg));
-    HIP_DEBUG_IN6ADDR("source address", ctx->src_addr);
-    HIP_DEBUG_IN6ADDR("destination address", ctx->dst_addr);
+    HIP_DEBUG_IN6ADDR("source address", &ctx->src_addr);
+    HIP_DEBUG_IN6ADDR("destination address", &ctx->dst_addr);
     HIP_DEBUG_HIT("Relay record hit", &rec->hit_r);
     HIP_DEBUG("Relay record port: %d.\n", rec->udp_port_r);
     HIP_DEBUG("source port: %u, destination port: %u\n",
-              ctx->msg_ports->src_port, ctx->msg_ports->dst_port);
+              ctx->msg_ports.src_port, ctx->msg_ports.dst_port);
 
     if (rec->type == HIP_RVSRELAY) {
         HIP_DEBUG("Relay type is RVS\n");
@@ -941,10 +955,10 @@
                       param_type);
             if (param_type == HIP_PARAM_RELAY_FROM) {
                 hip_build_param_relay_from(msg_to_be_relayed,
-                                           ctx->src_addr,
-                                           ctx->msg_ports->src_port);
+                                           &ctx->src_addr,
+                                           ctx->msg_ports.src_port);
             } else {
-                hip_build_param_from(msg_to_be_relayed, ctx->src_addr);
+                hip_build_param_from(msg_to_be_relayed, &ctx->src_addr);
             }
             hip_build_param(msg_to_be_relayed, current_param);
             from_added = 1;
@@ -959,10 +973,10 @@
                   param_type);
         if (param_type == HIP_PARAM_RELAY_FROM) {
             hip_build_param_relay_from(msg_to_be_relayed,
-                                       ctx->src_addr,
-                                       ctx->msg_ports->src_port);
+                                       &ctx->src_addr,
+                                       ctx->msg_ports.src_port);
         } else {
-            hip_build_param_from(msg_to_be_relayed, ctx->src_addr);
+            hip_build_param_from(msg_to_be_relayed, &ctx->src_addr);
         }
     }
 
@@ -1005,6 +1019,7 @@
  * forward a HIP control packet with relay_to parameter
  *
  * @param r the HIP control message to be relayed
+ * @param type_hdr message type
  * @param r_saddr the original source address
  * @param r_daddr the original destination address
  * @param relay_to_addr the address where to relay the packet
@@ -1064,11 +1079,6 @@
 /**
  * handle a HIP control message with relay_to parameter
  *
- * @param msg the message with the relay_to parameter
- * @param msg_type the type of the message
- * @param src_addr the source address of the message
- * @param dst_addr the destination address of the message
- * @param msg_info transport port numbers
  * @return zero on success or negative on error
  */
 int hip_relay_handle_relay_to(const uint8_t packet_type,
@@ -1121,8 +1131,8 @@
                   ntohs(relay_to->port));
         hip_relay_forward_response(ctx->input_msg,
                                    packet_type,
-                                   ctx->src_addr,
-                                   ctx->dst_addr,
+                                   &ctx->src_addr,
+                                   &ctx->dst_addr,
                                    &relay_to->address,
                                    ntohs(relay_to->port));
         //  state = HIP_STATE_NONE;
@@ -1206,7 +1216,8 @@
             HIP_DEBUG("Found FROM parameter in I1.\n");
             param_type = HIP_PARAM_FROM;
             memcpy(dest_ip, &from->address, sizeof(from->address));
-            *dest_port = ntohs(relay_from->port);
+            /* No port number in RVS FROM. hip_send_r1() fills in this later */
+            *dest_port = 0;
             HIP_DEBUG("FROM port in I1: %d \n", *dest_port);
         }
     } else {
@@ -1275,12 +1286,6 @@
 /**
  * handle the relay_to parameter at the Initiator
  *
- * @param msg the HIP control packet with relay_to parameter
- * @param msg_type the type of the HIP control message
- * @param src_addr source address of the message
- * @param dst_addr destination address of the message
- * @param msg_info transport layer port information
- * @param entry the host association
  * @return zero on success or negative on error
  */
 int hip_relay_handle_relay_to_in_client(const uint8_t packet_type,

=== modified file 'hipd/hiprelay.h'
--- hipd/hiprelay.h     2010-08-19 09:32:20 +0000
+++ hipd/hiprelay.h     2010-10-15 15:29:14 +0000
@@ -1,6 +1,5 @@
-/** @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -22,9 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
- * A header file for hiprelay.c.
- *
+ */
+
+/**
+ * @file
  * @author  Lauri Silvennoinen
  * @note    Related draft:
  *          <a 
href="http://www.ietf.org/internet-drafts/draft-ietf-hip-nat-traversal-03.txt";>

=== modified file 'hipd/hit_to_ip.c'
--- hipd/hit_to_ip.c    2010-08-29 16:24:14 +0000
+++ hipd/hit_to_ip.c    2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * @brief look for locators in hit-to-ip domain
  * @brief usually invoked by hip_map_id_to_addr
  *

=== modified file 'hipd/hit_to_ip.h'
--- hipd/hit_to_ip.h    2010-08-19 09:32:20 +0000
+++ hipd/hit_to_ip.h    2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * @brief look for locators in hit-to-ip domain
  * @brief usually invoked by hip_map_id_to_addr
  *

=== modified file 'hipd/init.c'
--- hipd/init.c 2010-09-08 14:44:25 +0000
+++ hipd/init.c 2010-11-09 16:37:54 +0000
@@ -1,6 +1,5 @@
-/** @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -22,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This file defines initialization functions for the HIP daemon.
  *
  * @note    HIPU: BSD platform needs to be autodetected in 
hip_set_lowcapability
@@ -158,7 +160,7 @@
     "# Format of this file is as with hipconf, but without hipconf prefix\n\
 # add hi default    # add all four HITs (see bug id 592127)\n\
 # add map HIT IP    # preload some HIT-to-IP mappings to hipd\n\
-# add service rvs   # the host acts as HIP rendezvous (see also 
/etc/hip/relay_config)\n\
+# add service rvs   # the host acts as HIP rendezvous (see also 
HIPL_SYSCONFDIR/relay_config)\n\
 # add server rvs [RVS-HIT] <RVS-IP-OR-HOSTNAME> <lifetime-secs> # register to 
rendezvous server\n\
 # add server relay [RELAY-HIT] <RVS-IP-OR-HOSTNAME> <lifetime-secs> # register 
to relay server\n\
 # add server full-relay [RELAY-HIT] <RVS-IP-OR-HOSTNAME> <lifetime-secs> # 
register to relay server\n\
@@ -574,7 +576,8 @@
 
     /* Create default keys if necessary. */
 
-    if (stat(HIPL_SYSCONFDIR "/" DEFAULT_HOST_RSA_KEY_FILE_BASE 
DEFAULT_PUB_HI_FILE_NAME_SUFFIX, &status) && errno == ENOENT) {
+    if (stat(HIPL_SYSCONFDIR DEFAULT_HOST_RSA_KEY_FILE_BASE 
DEFAULT_PUB_HI_FILE_NAME_SUFFIX,
+             &status) && errno == ENOENT) {
         HIP_IFEL(hip_serialize_host_id_action(user_msg, ACTION_NEW, 0, 1,
                                               NULL, NULL, RSA_KEY_DEFAULT_BITS,
                                               DSA_KEY_DEFAULT_BITS),

=== modified file 'hipd/init.h'
--- hipd/init.h 2010-07-07 16:42:17 +0000
+++ hipd/init.h 2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'hipd/input.c'
--- hipd/input.c        2010-09-10 14:33:51 +0000
+++ hipd/input.c        2010-11-09 16:37:54 +0000
@@ -1,19 +1,5 @@
-/** @file
- * This file defines handling functions for incoming packets for the Host
- * Identity Protocol (HIP).
- *
- * @author  Janne Lundberg
- * @author  Miika Komu
- * @author  Mika Kousa
- * @author  Kristian Slavov
- * @author  Anthony D. Joseph
- * @author  Bing Zhou
- * @author  Tobias Heer
- * @author  Laura Takkinen
- * @author  Rene Hummen
- * @author  Samu Varjonen
- * @author  Tim Just
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -37,6 +23,24 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
+/**
+ * @file
+ * This file defines handling functions for incoming packets for the Host
+ * Identity Protocol (HIP).
+ *
+ * @author  Janne Lundberg
+ * @author  Miika Komu
+ * @author  Mika Kousa
+ * @author  Kristian Slavov
+ * @author  Anthony D. Joseph
+ * @author  Bing Zhou
+ * @author  Tobias Heer
+ * @author  Laura Takkinen
+ * @author  Rene Hummen
+ * @author  Samu Varjonen
+ * @author  Tim Just
+ */
+
 #define _BSD_SOURCE
 
 #include <errno.h>
@@ -520,8 +524,8 @@
     HIP_DEBUG_HIT("HIT Sender  ", &ctx->input_msg->hits);
     HIP_DEBUG_HIT("HIT Receiver", &ctx->input_msg->hitr);
     HIP_DEBUG("source port: %u, destination port: %u\n",
-              ctx->msg_ports->src_port,
-              ctx->msg_ports->dst_port);
+              ctx->msg_ports.src_port,
+              ctx->msg_ports.dst_port);
 
     HIP_DUMP_MSG(ctx->input_msg);
 
@@ -530,9 +534,9 @@
                             &ctx->input_msg->hits) ||
          IN6_ARE_ADDR_EQUAL(&ctx->input_msg->hitr,
                             &ipv6_any_addr)) &&
-        !hip_addr_is_loopback(ctx->dst_addr) &&
-        !hip_addr_is_loopback(ctx->src_addr) &&
-        !IN6_ARE_ADDR_EQUAL(ctx->src_addr, ctx->dst_addr)) {
+        !hip_addr_is_loopback(&ctx->dst_addr) &&
+        !hip_addr_is_loopback(&ctx->src_addr) &&
+        !IN6_ARE_ADDR_EQUAL(&ctx->src_addr, &ctx->dst_addr)) {
         HIP_DEBUG("Invalid loopback packet. Dropping.\n");
         goto out_err;
     }
@@ -563,7 +567,7 @@
         (type == HIP_I1 || type == HIP_R1)) {
         ctx->hadb_entry =
                 hip_oppdb_get_hadb_entry_i1_r1(ctx->input_msg,
-                                               ctx->src_addr);
+                                               &ctx->src_addr);
     }
 #endif
 
@@ -649,7 +653,7 @@
          * used for setting up the SAs: handle_r1 creates one-way SA and
          * handle_i2 the other way; let's make sure that they are the
          * same. */
-        ctx->src_addr = &entry->peer_addr;
+        ipv6_addr_copy(&ctx->src_addr, &entry->peer_addr);
     }
 #endif
     HIP_IFEL(hip_receive_control_packet(ctx), -1,
@@ -732,18 +736,18 @@
      * newer address. This enables us to use the rendezvous server, while
      * not supporting the REA TLV. */
     hip_hadb_get_peer_addr(ctx->hadb_entry, &daddr);
-    if (ipv6_addr_cmp(&daddr, ctx->src_addr) != 0) {
+    if (ipv6_addr_cmp(&daddr, &ctx->src_addr) != 0) {
         HIP_DEBUG("Mapped address didn't match received address\n");
         HIP_DEBUG("Assuming that the mapped address was actually RVS's.\n");
         HIP_HEXDUMP("Mapping", &daddr, 16);
-        HIP_HEXDUMP("Received", ctx->src_addr, 16);
+        HIP_HEXDUMP("Received", &ctx->src_addr, 16);
         hip_hadb_delete_peer_addrlist_one_old(ctx->hadb_entry, &daddr);
         hip_hadb_add_peer_addr(ctx->hadb_entry,
-                               ctx->src_addr,
+                               &ctx->src_addr,
                                0,
                                0,
                                PEER_ADDR_STATE_ACTIVE,
-                               ctx->msg_ports->src_port);
+                               ctx->msg_ports.src_port);
     }
 
     hip_relay_add_rvs_to_ha(ctx->input_msg, ctx->hadb_entry);
@@ -843,13 +847,11 @@
      * the peer is behind NAT. We set NAT mode "on" and set the send function 
to
      * "hip_send_udp". The client UDP port is not stored until the handling
      * of R2 packet. Don't know if the entry is already locked... */
-    if (ctx->msg_ports->dst_port != 0) {
+    if (ctx->msg_ports.dst_port != 0) {
         HIP_LOCK_HA(ctx->hadb_entry);
         if (ctx->hadb_entry->nat_mode == HIP_NAT_MODE_NONE) {
             ctx->hadb_entry->nat_mode = HIP_NAT_MODE_PLAIN_UDP;
         }
-        /* @todo Is this alternative xmit function necessary? */
-        /* hip_hadb_set_xmit_function_set(entry, &nat_xmit_func_set); */
         HIP_UNLOCK_HA(ctx->hadb_entry);
     }
 
@@ -897,13 +899,9 @@
         solved_puzzle = ctx->hadb_entry->puzzle_solution;
     }
 
-    /* Allocate space for a new I2 message. */
-    HIP_IFEL(!(ctx->output_msg = hip_msg_alloc()),
-             -ENOMEM,
-             "Allocation of I2 failed\n");
-
     HIP_DEBUG("Build normal I2.\n");
     /* create I2 */
+    hip_msg_init(ctx->output_msg);
     hip_build_network_hdr(ctx->output_msg,
                           HIP_I2,
                           i2_mask,
@@ -1093,9 +1091,9 @@
     }
 
     /* if the NAT mode is used, update the port numbers of the host 
association */
-    if (ctx->msg_ports->dst_port == hip_get_local_nat_udp_port()) {
-        ctx->hadb_entry->local_udp_port = ctx->msg_ports->dst_port;
-        ctx->hadb_entry->peer_udp_port  = ctx->msg_ports->src_port;
+    if (ctx->msg_ports.dst_port == hip_get_local_nat_udp_port()) {
+        ctx->hadb_entry->local_udp_port = ctx->msg_ports.dst_port;
+        ctx->hadb_entry->peer_udp_port  = ctx->msg_ports.src_port;
     }
 
     HIP_IFEL(!(esp_info = hip_get_param(ctx->input_msg, HIP_PARAM_ESP_INFO)),
@@ -1242,7 +1240,7 @@
     hip_perf_start_benchmark(perf_set, PERF_I1);
 #endif
     HIP_INFO_HIT("I1 Source HIT:", &(ctx->input_msg)->hits);
-    HIP_INFO_IN6ADDR("I1 Source IP :", ctx->src_addr);
+    HIP_INFO_IN6ADDR("I1 Source IP :", &ctx->src_addr);
 
     HIP_ASSERT(!ipv6_addr_any(&(ctx->input_msg)->hitr));
 
@@ -1329,10 +1327,10 @@
     src_hit_is_our = hip_hidb_hit_is_our(&ctx->input_msg->hits);
 
     /* check i1 for broadcast/multicast addresses */
-    if (IN6_IS_ADDR_V4MAPPED(ctx->dst_addr)) {
+    if (IN6_IS_ADDR_V4MAPPED(&ctx->dst_addr)) {
         struct in_addr addr4;
 
-        IPV6_TO_IPV4_MAP(ctx->dst_addr, &addr4);
+        IPV6_TO_IPV4_MAP(&ctx->dst_addr, &addr4);
 
         if (addr4.s_addr == INADDR_BROADCAST) {
             HIP_DEBUG("Received I1 broadcast\n");
@@ -1341,17 +1339,17 @@
                     ctx->error = 1,
                     "Received a copy of own broadcast, dropping\n");
 
-            HIP_IFF(hip_select_source_address(ctx->dst_addr, ctx->src_addr),
+            HIP_IFF(hip_select_source_address(&ctx->dst_addr, &ctx->src_addr),
                     -1,
                     ctx->error = 1,
                     "Could not find source address\n");
         }
-    } else if (IN6_IS_ADDR_MULTICAST(ctx->dst_addr)) {
+    } else if (IN6_IS_ADDR_MULTICAST(&ctx->dst_addr)) {
         HIP_IFF(src_hit_is_our,
                 -1,
                 ctx->error = 1,
                 "Received a copy of own broadcast, dropping\n");
-        HIP_IFF(hip_select_source_address(ctx->dst_addr, ctx->src_addr),
+        HIP_IFF(hip_select_source_address(&ctx->dst_addr, &ctx->src_addr),
                 -1,
                 ctx->error = 1,
                 "Could not find source address\n");
@@ -1435,7 +1433,7 @@
     HIP_DEBUG("Received I2 in state %s\n", hip_state_str(ha_state));
     HIP_INFO("Received I2 from:\n");
     HIP_INFO_HIT("Source HIT:", &ctx->input_msg->hits);
-    HIP_INFO_IN6ADDR("Source IP: ", ctx->src_addr);
+    HIP_INFO_IN6ADDR("Source IP: ", &ctx->src_addr);
 
     /* Next, we initialize the new HIP association. Peer HIT is the
       * source HIT of the received I2 packet. We can have many Host
@@ -1457,7 +1455,7 @@
                   "association. Dropping the I2 packet.\n");
      }
      ipv6_addr_copy(&ctx->hadb_entry->hit_peer, &ctx->input_msg->hits);
-     ipv6_addr_copy(&ctx->hadb_entry->our_addr, ctx->dst_addr);
+     ipv6_addr_copy(&ctx->hadb_entry->our_addr, &ctx->dst_addr);
      HIP_DEBUG("Initializing the HIP association.\n");
      hip_init_us(ctx->hadb_entry, &ctx->input_msg->hitr);
      hip_hadb_insert_state(ctx->hadb_entry);
@@ -1471,8 +1469,8 @@
              -ENODATA,
              "SOLUTION parameter missing from I2 packet. Dropping\n");
 
-    HIP_IFEL(hip_verify_cookie(ctx->src_addr,
-                               ctx->dst_addr,
+    HIP_IFEL(hip_verify_cookie(&ctx->src_addr,
+                               &ctx->dst_addr,
                                ctx->input_msg,
                                solution),
              -EPROTO,
@@ -1727,16 +1725,14 @@
      * stored as the peer UDP port and send function is set to
      * "hip_send_pkt()". Note that we must store the port not until
      * here, since the source port can be different for I1 and I2. */
-    if (ctx->msg_ports->dst_port != 0) {
+    if (ctx->msg_ports.dst_port != 0) {
         if (ctx->hadb_entry->nat_mode == 0) {
             ctx->hadb_entry->nat_mode = HIP_NAT_MODE_PLAIN_UDP;
         }
-        ctx->hadb_entry->local_udp_port = ctx->msg_ports->dst_port;
-        ctx->hadb_entry->peer_udp_port  = ctx->msg_ports->src_port;
+        ctx->hadb_entry->local_udp_port = ctx->msg_ports.dst_port;
+        ctx->hadb_entry->peer_udp_port  = ctx->msg_ports.src_port;
         HIP_DEBUG("Setting send func to UDP for entry %p from I2 info.\n",
                   ctx->hadb_entry);
-        /** @todo Is this function set needed ? */
-        /*hip_hadb_set_xmit_function_set(ctx->hadb_entry, 
&nat_xmit_func_set);*/
     }
 
     HIP_IFEL(!(esp_info = hip_get_param(ctx->input_msg, HIP_PARAM_ESP_INFO)),
@@ -1749,11 +1745,11 @@
     ctx->hadb_entry->peer_controls |= ntohs(ctx->input_msg->control);
 
     HIP_IFEL(hip_hadb_add_peer_addr(ctx->hadb_entry,
-                                    ctx->src_addr,
+                                    &ctx->src_addr,
                                     0,
                                     0,
                                     PEER_ADDR_STATE_ACTIVE,
-                                    ctx->msg_ports->src_port),
+                                    ctx->msg_ports.src_port),
              -1,
              "Error while adding the preferred peer address\n");
 
@@ -1959,11 +1955,7 @@
                     port = hip_get_peer_nat_udp_port();
                 }
 
-                /* We don't need to use hip_msg_alloc(), since
-                 * the I1 packet is just the size of struct
-                 * hip_common. */
-                memset(ctx->output_msg, 0, sizeof(ctx->output_msg));
-
+                hip_msg_init(ctx->output_msg);
                 hip_build_network_hdr(ctx->output_msg,
                                       response,
                                       ctx->hadb_entry->local_controls,

=== modified file 'hipd/input.h'
--- hipd/input.h        2010-09-08 14:44:25 +0000
+++ hipd/input.h        2010-11-09 16:37:54 +0000
@@ -1,17 +1,5 @@
-/** @file
- * A header file for input.c.
- *
- * @author  Janne Lundberg
- * @author  Miika Komu
- * @author  Mika Kousa
- * @author  Kristian Slavov
- * @author  Anthony D. Joseph
- * @author  Bing Zhou
- * @author  Tobias Heer
- * @author  Samu Varjonen
- * @author  Rene Hummen
- * @author  Tim Just
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -35,6 +23,20 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
+/**
+ * @file
+ * @author  Janne Lundberg
+ * @author  Miika Komu
+ * @author  Mika Kousa
+ * @author  Kristian Slavov
+ * @author  Anthony D. Joseph
+ * @author  Bing Zhou
+ * @author  Tobias Heer
+ * @author  Samu Varjonen
+ * @author  Rene Hummen
+ * @author  Tim Just
+ */
+
 #ifndef HIP_HIPD_INPUT_H
 #define HIP_HIPD_INPUT_H
 

=== modified file 'hipd/keymat.c'
--- hipd/keymat.c       2010-08-29 16:24:14 +0000
+++ hipd/keymat.c       2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This file contains KEYMAT handling functions for HIPL
  *
  * @author Mika Kousa <mkousa#iki.fi>

=== modified file 'hipd/keymat.h'
--- hipd/keymat.h       2010-07-07 16:42:17 +0000
+++ hipd/keymat.h       2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'hipd/maintenance.c'
--- hipd/maintenance.c  2010-09-03 11:56:17 +0000
+++ hipd/maintenance.c  2010-11-09 16:37:54 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * Periodically handled "maintenance" actions are processed here by
  * default roughly once in a second. These actions include
  * retransmissions of lost HIP control packets, keepalives for NATs,

=== modified file 'hipd/maintenance.h'
--- hipd/maintenance.h  2010-07-07 16:42:17 +0000
+++ hipd/maintenance.h  2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'hipd/nat.c'
--- hipd/nat.c  2010-07-16 18:56:20 +0000
+++ hipd/nat.c  2010-10-22 10:41:25 +0000
@@ -1,4 +1,30 @@
-/** @file
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file
  * This file defines extensions to Host Identity Protocol (HIP) to support
  * traversal of Network Address Translator (NAT) middleboxes.
  *
@@ -20,28 +46,6 @@
  *          <li><a 
href="http://www.ietf.org/internet-drafts/draft-irtf-hiprg-nat-03.txt";>
  *          draft-irtf-hiprg-nat-03</a></li>
  *          </ul>
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use,
- * copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following
- * conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
  * @note    All Doxygen comments have been added in version 1.1.
  */
 
@@ -194,7 +198,6 @@
 {
     int err = 0;
     if (entry && mode != HIP_NAT_MODE_NONE) {
-        //hip_hadb_set_xmit_function_set(entry, &nat_xmit_func_set);
         entry->nat_mode = *((hip_transform_suite_t *) mode);
         HIP_DEBUG("NAT status of host association %p: %d\n",
                   entry, entry->nat_mode);

=== modified file 'hipd/nat.h'
--- hipd/nat.h  2010-07-07 16:42:17 +0000
+++ hipd/nat.h  2010-10-15 15:29:14 +0000
@@ -1,18 +1,5 @@
-/** @file
- * A header file for nat.c
- *
- * @author  (version 1.0) Abhinav Pathak
- * @author  (version 1.1) Lauri Silvennoinen
- * @version 1.1
- * @date    27.10.2006
- * @note    Related drafts:
- *          <ul>
- *          <li><a 
href="http://www.ietf.org/internet-drafts/draft-schmitt-hip-nat-traversal-02.txt";>
- *          draft-schmitt-hip-nat-traversal-02</a></li>
- *          <li><a 
href="http://www.ietf.org/internet-drafts/draft-irtf-hiprg-nat-03.txt";>
- *          draft-irtf-hiprg-nat-03</a></li>
- *          </ul>
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -34,6 +21,21 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file
+ * @author  (version 1.0) Abhinav Pathak
+ * @author  (version 1.1) Lauri Silvennoinen
+ * @version 1.1
+ * @date    27.10.2006
+ * @note    Related drafts:
+ *          <ul>
+ *          <li><a 
href="http://www.ietf.org/internet-drafts/draft-schmitt-hip-nat-traversal-02.txt";>
+ *          draft-schmitt-hip-nat-traversal-02</a></li>
+ *          <li><a 
href="http://www.ietf.org/internet-drafts/draft-irtf-hiprg-nat-03.txt";>
+ *          draft-irtf-hiprg-nat-03</a></li>
+ *          </ul>
  * @note    All Doxygen comments have been added in version 1.1.
  */
 

=== modified file 'hipd/netdev.c'
--- hipd/netdev.c       2010-08-25 09:06:43 +0000
+++ hipd/netdev.c       2010-10-27 11:27:48 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This file contains a collection of address management related functions 
including:
  * - an up-to-date cache of localhost addresses
  * - whitelist functionality to exclude some (e.g. expensive or incompatible) 
network interfaces
@@ -45,6 +46,7 @@
 #include <ifaddrs.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <unistd.h>
 #include <arpa/inet.h>
 #include <net/if.h>
@@ -178,22 +180,32 @@
     const struct netdev_address *na = (const struct netdev_address *) ptr;
     uint8_t hash[HIP_AH_SHA_LEN];
 
+    /* stg: TODO A cryptographically secure hash is unnecessarily expensive 
for a hash table. Something cheaper, like an XOR, would do just fine. */
     hip_build_digest(HIP_DIGEST_SHA1, &na->addr,
                      sizeof(struct sockaddr_storage), hash);
 
+    /* stg: TODO Returning only a long is all the more reason to move to a 
cheaper hash function. */
     return *((unsigned long *) hash);
 }
 
 /**
  * equality function for the addresses hash table
  *
+ * Note that when this function is called, the hashes of the two hash table
+ * entries provided as arguments are known to be equal.
+ * The point of this function is to allow the hash table to determine whether
+ * the entries (or rather the part used to calculate the hash) themselves are
+ * equal or whether they are different and this is just a hash collision.
+ *
  * @param ptr1 a pointer to a netdev_address structure
  * @param ptr2 a pointer to a netdev_address structure
  * @return 0 if the given pointers match or 1 otherwise
  */
 static int hip_netdev_match(const void *ptr1, const void *ptr2)
 {
-    return hip_netdev_hash(ptr1) != hip_netdev_hash(ptr2);
+    const struct netdev_address *na1 = (const struct netdev_address *) ptr1;
+    const struct netdev_address *na2 = (const struct netdev_address *) ptr2;
+    return memcmp(&na1->addr, &na2->addr, sizeof(na1->addr));
 }
 
 /**
@@ -712,13 +724,13 @@
         goto out_err;
     }
 
-    /* Try to resolve the HIT or LSI to a hostname from /etc/hip/hosts,
+    /* Try to resolve the HIT or LSI to a hostname from HIPL_SYSCONFDIR/hosts,
      * then resolve the hostname to an IP, and a HIT or LSI,
      * depending on dst_hit value.
      * If dst_hit is a HIT -> find LSI and hostname
      * If dst_hit is an LSI -> find HIT and hostname */
 
-    /* try to resolve HIT to IPv4/IPv6 address by '/etc/hip/hosts'
+    /* try to resolve HIT to IPv4/IPv6 address by 'HIPL_SYSCONFDIR/hosts'
      * and '/etc/hosts' files
      */
     HIP_IFEL(!hip_map_id_to_ip_from_hosts_files(hit, lsi, addr),

=== modified file 'hipd/netdev.h'
--- hipd/netdev.h       2010-08-19 09:32:20 +0000
+++ hipd/netdev.h       2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -24,7 +22,9 @@
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
  */
-/*
+
+/**
+ * @file
  * The component provides interface to receive IP address and IF
  * events over netlink from the kernel.
  */

=== modified file 'hipd/nsupdate.c'
--- hipd/nsupdate.c     2010-08-29 16:24:14 +0000
+++ hipd/nsupdate.c     2010-10-27 11:27:48 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * @brief Update DNS data for the hit-to-ip domain name.
  * @brief It executes an external perl script for each HIT
  * @brief and passes it a list of the current IP addresses.
@@ -36,6 +37,7 @@
 
 #define _BSD_SOURCE
 
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>

=== modified file 'hipd/nsupdate.h'
--- hipd/nsupdate.h     2010-07-30 12:41:09 +0000
+++ hipd/nsupdate.h     2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * @brief Update DNS data for the hit-to-ip domain name.
  * @brief It executes an external perl script for each HIT
  * @brief and passes it a list of the current IP addresses.

=== modified file 'hipd/oppdb.c'
--- hipd/oppdb.c        2010-08-20 14:34:13 +0000
+++ hipd/oppdb.c        2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * Opportunistic mode databases for lib/opphip and HIP registration. The 
system-based
  * opportunistic mode in the firewall uses also this functionality to trigger 
an
  * opportunistic base base exchange. See the following publication on the 
details:
@@ -51,8 +52,7 @@
  * process which means that it should proceed without HIP. Consequtive
  * rejects are faster because they are cached.
  *
- * Authors:
- * - Bing Zhou <bingzhou@xxxxxxxxx>
+ * @author Bing Zhou <bingzhou@xxxxxxxxx>
  */
 
 #include <errno.h>
@@ -121,13 +121,21 @@
 /**
  * matching function for the hashtable implementation
  *
+ * Note that when this function is called, the hashes of the two hash table
+ * entries provided as arguments are known to be equal.
+ * The point of this function is to allow the hash table to determine whether
+ * the entries (or rather the part used to calculate the hash) themselves are
+ * equal or whether they are different and this is just a hash collision.
+ *
  * @param ptr1 a pointer to a hip_opp_block_t structure
  * @param ptr2 a pointer to a hip_opp_block_t structure
  * @return zero on match or non-zero otherwise
  */
 static int hip_oppdb_match_hit(const void *ptr1, const void *ptr2)
 {
-    return hip_hash_hit(ptr1) != hip_hash_hit(ptr2);
+    const hip_opp_block_t *b1 = (const hip_opp_block_t *) ptr1;
+    const hip_opp_block_t *b2 = (const hip_opp_block_t *) ptr2;
+    return memcmp(&b1->peer_phit, &b2->peer_phit, sizeof(hip_hit_t) + 
sizeof(struct sockaddr_in6));
 }
 
 /**
@@ -491,8 +499,8 @@
     HIP_IFEL(hip_hadb_add_peer_info_complete(&ctx->input_msg->hitr,
                                              &ctx->input_msg->hits,
                                              NULL,
-                                             ctx->dst_addr,
-                                             ctx->src_addr,
+                                             &ctx->dst_addr,
+                                             &ctx->src_addr,
                                              NULL),
              -1, "Failed to insert peer map\n");
 
@@ -515,15 +523,15 @@
     HIP_DEBUG_HIT("peer hit", &ctx->input_msg->hits);
     HIP_DEBUG_HIT("local hit", &ctx->input_msg->hitr);
 
-    HIP_IFEL(hip_opportunistic_ipv6_to_hit(ctx->src_addr, &phit,
+    HIP_IFEL(hip_opportunistic_ipv6_to_hit(&ctx->src_addr, &phit,
                                            HIP_HIT_TYPE_HASH100),
              -1, "pseudo hit conversion failed\n");
 
     ipv6_addr_copy(&opp_info.real_peer_hit, &ctx->input_msg->hits);
     ipv6_addr_copy(&opp_info.pseudo_peer_hit, &phit);
     ipv6_addr_copy(&opp_info.local_hit, &ctx->input_msg->hitr);
-    ipv6_addr_copy(&opp_info.local_addr, ctx->dst_addr);
-    ipv6_addr_copy(&opp_info.peer_addr, ctx->src_addr);
+    ipv6_addr_copy(&opp_info.local_addr, &ctx->dst_addr);
+    ipv6_addr_copy(&opp_info.peer_addr, &ctx->src_addr);
 
     hip_for_each_opp(hip_oppdb_unblock_group, &opp_info);
     hip_del_peer_info_entry(opp_entry);

=== modified file 'hipd/oppdb.h'
--- hipd/oppdb.h        2010-07-07 16:42:17 +0000
+++ hipd/oppdb.h        2010-10-15 15:29:14 +0000
@@ -1,57 +1,31 @@
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
 /**
  * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use,
- * copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following
- * conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-/*
- * hipd oppdb.h
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use,
- * copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following
- * conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- * Authors:
- * - Bing Zhou <bingzhou@xxxxxxxxx>
- *
+ * @author Bing Zhou <bingzhou@xxxxxxxxx>
  */
 
 #ifndef HIP_HIPD_OPPDB_H

=== modified file 'hipd/oppipdb.c'
--- hipd/oppipdb.c      2010-08-29 16:24:14 +0000
+++ hipd/oppipdb.c      2010-10-15 15:29:14 +0000
@@ -1,6 +1,5 @@
-/** @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -22,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This file defines handling functions for opportunistic mode to remember
  * IP's which are not HIP capable. This means faster communication in second
  * connection attempts to these hosts. Otherwise it would always take the same
@@ -67,16 +69,22 @@
 }
 
 /**
- * Compares two ip addresses using their hashes
+ * Compares two ip addresses.
+ *
+ * Note that when this function is called, the hashes of the two hash table
+ * entries provided as arguments are known to be equal.
+ * The point of this function is to allow the hash table to determine whether
+ * the entries (or rather the part used to calculate the hash) themselves are
+ * equal or whether they are different and this is just a hash collision.
  *
  * @param ptr1: pointer to the first ip address to compare
  * @param ptr2: pointer to the second ip address to compare
  *
- * @return 0 if the ip hashes are identical, 1 if they are different
+ * @return 0 if the ips are identical, 1 if they are different
  */
 static int hip_oppipdb_match_ip(const void *ptr1, const void *ptr2)
 {
-    return hip_oppipdb_hash_ip(ptr1) != hip_oppipdb_hash_ip(ptr2);
+    return memcmp(ptr1, ptr2, sizeof(hip_oppip_t));
 }
 
 /**

=== modified file 'hipd/oppipdb.h'
--- hipd/oppipdb.h      2010-07-07 16:42:17 +0000
+++ hipd/oppipdb.h      2010-10-15 15:29:14 +0000
@@ -1,9 +1,5 @@
-/** @file
- * oppipdb.h: A header file for oppipdb.c
- *
- * @author  Antti Partanen
- * @author  Alberto Garcia
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -27,6 +23,12 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
+/**
+ * @file
+ * @author  Antti Partanen
+ * @author  Alberto Garcia
+ */
+
 #ifndef HIP_HIPD_OPPIPDB_H
 #define HIP_HIPD_OPPIPDB_H
 

=== modified file 'hipd/output.c'
--- hipd/output.c       2010-09-08 16:28:02 +0000
+++ hipd/output.c       2010-11-09 16:37:54 +0000
@@ -1,6 +1,5 @@
-/* @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -22,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This file defines processing of outgoing packets for the Host
  * Identity Protocol (HIP).
  *
@@ -378,8 +380,8 @@
      * of the REG_INFO parameter. */
 
     HIP_DEBUG("R1 source port %u, destination port %d\n",
-              ctx->msg_ports->src_port,
-              ctx->msg_ports->dst_port);
+              ctx->msg_ports.src_port,
+              ctx->msg_ports.dst_port);
 
     HIP_ASSERT(ctx->hadb_entry);
 
@@ -534,11 +536,11 @@
      * try to set up inbound IPsec SA, similarly as in hip_send_r2 */
 
     HIP_DEBUG("src %d, dst %d\n",
-              ctx->msg_ports->src_port,
-              ctx->msg_ports->dst_port);
+              ctx->msg_ports.src_port,
+              ctx->msg_ports.dst_port);
 
-    ctx->hadb_entry->local_udp_port = ctx->msg_ports->src_port;
-    ctx->hadb_entry->peer_udp_port  = ctx->msg_ports->dst_port;
+    ctx->hadb_entry->local_udp_port = ctx->msg_ports.src_port;
+    ctx->hadb_entry->peer_udp_port  = ctx->msg_ports.dst_port;
 
     ctx->hadb_entry->hip_transform  = transform_hip_suite;
 
@@ -578,9 +580,9 @@
     HIP_IFE(hip_hadb_get_peer_addr(ctx->hadb_entry, &daddr), -1);
 
     /* R1 packet source port becomes the I2 packet destination port. */
-    err = hip_send_pkt(ctx->dst_addr, &daddr,
+    err = hip_send_pkt(&ctx->dst_addr, &daddr,
                        (ctx->hadb_entry->nat_mode ? 
hip_get_local_nat_udp_port() : 0),
-                       ctx->msg_ports->src_port, ctx->output_msg, 
ctx->hadb_entry, 1);
+                       ctx->msg_ports.src_port, ctx->output_msg, 
ctx->hadb_entry, 1);
     HIP_IFEL(err < 0, -ECOMM, "Sending I2 packet failed.\n");
 
     HIP_IFEL(err < 0, -1, "Creation of I2 failed\n");
@@ -590,9 +592,6 @@
     }
 
 out_err:
-    if (ctx->output_msg) {
-        free(ctx->output_msg);
-    }
 #ifdef CONFIG_HIP_PERFORMANCE
     HIP_DEBUG("Stop and write PERF_R1\n");
     hip_perf_stop_benchmark(perf_set, PERF_R1);
@@ -820,7 +819,7 @@
     struct in6_addr dst_ip      = IN6ADDR_ANY_INIT,
                *r1_dst_addr     = NULL,
                *local_plain_hit = NULL,
-               *r1_src_addr     = ctx->dst_addr;
+               *r1_src_addr     = &ctx->dst_addr;
     in_port_t r1_dst_port       = 0;
     int relay_para_type         = 0;
 
@@ -828,12 +827,12 @@
              -1,
              "Abort packet processing and don't send R1 packet.\n")
 
-    HIP_DEBUG_IN6ADDR("i1_saddr", ctx->src_addr);
-    HIP_DEBUG_IN6ADDR("i1_daddr", ctx->dst_addr);
+    HIP_DEBUG_IN6ADDR("i1_saddr", &ctx->src_addr);
+    HIP_DEBUG_IN6ADDR("i1_daddr", &ctx->dst_addr);
     HIP_DEBUG_IN6ADDR("dst_ip", &dst_ip);
 
     relay_para_type = hip_relay_handle_relay_from(ctx->input_msg,
-                                                  ctx->src_addr,
+                                                  &ctx->src_addr,
                                                   &dst_ip, &r1_dst_port);
 
     /* Get the final destination address and port for the outgoing R1.
@@ -844,13 +843,13 @@
         if (relay_para_type == HIP_PARAM_RELAY_FROM) {
             HIP_DEBUG("Param relay from\n");
             //from relay
-            r1_dst_addr = ctx->src_addr;
-            r1_dst_port = ctx->msg_ports->src_port;
+            r1_dst_addr = &ctx->src_addr;
+            r1_dst_port = ctx->msg_ports.src_port;
         } else if (relay_para_type == HIP_PARAM_FROM)    {
             HIP_DEBUG("Param from\n");
             //from RVS, answer to I
             r1_dst_addr =  &dst_ip;
-            if (ctx->msg_ports->src_port) {
+            if (ctx->msg_ports.src_port) {
                 // R and RVS is in the UDP mode or I send UDP to RVS with 
incoming port hip_get_peer_nat_udp_port()
                 r1_dst_port =  hip_get_peer_nat_udp_port();
             } else {
@@ -861,8 +860,8 @@
     } else {
         HIP_DEBUG("No RVS or relay\n");
         /* no RVS or RELAY found;  direct connection */
-        r1_dst_addr = ctx->src_addr;
-        r1_dst_port = ctx->msg_ports->src_port;
+        r1_dst_addr = &ctx->src_addr;
+        r1_dst_port = ctx->msg_ports.src_port;
     }
 
 #ifdef CONFIG_HIP_OPPORTUNISTIC
@@ -885,7 +884,7 @@
         }
     }
 
-    HIP_IFEL(!(r1pkt = hip_get_r1(r1_dst_addr, ctx->dst_addr,
+    HIP_IFEL(!(r1pkt = hip_get_r1(r1_dst_addr, &ctx->dst_addr,
                                   &ctx->input_msg->hitr)),
              -ENOENT, "No precreated R1\n");
 
@@ -909,7 +908,7 @@
             hip_build_param_relay_to(r1pkt, &dst_ip, r1_dst_port);
         } else if (relay_para_type == HIP_PARAM_FROM)    {
             HIP_DEBUG("Build param via_rvs\n");
-            hip_build_param_via_rvs(r1pkt, ctx->src_addr);
+            hip_build_param_via_rvs(r1pkt, &ctx->src_addr);
         }
     }
 #endif
@@ -1081,7 +1080,7 @@
              "Abort packet processing and don't send R1 packet.\n")
 
     /* Build and send R2: IP ( HIP ( SPI, HMAC, HIP_SIGNATURE ) ) */
-    HIP_IFEL(!(ctx->output_msg = hip_msg_alloc()), -ENOMEM, "No memory for 
R2\n");
+    hip_msg_init(ctx->output_msg);
 
     /* Just swap the addresses to use the I2's destination HIT as the R2's
      * source HIT. */
@@ -1144,8 +1143,8 @@
 {
     int err = 0;
 
-    err = hip_send_pkt(ctx->dst_addr,
-                       ctx->src_addr,
+    err = hip_send_pkt(&ctx->dst_addr,
+                       &ctx->src_addr,
                        (ctx->hadb_entry->nat_mode ? 
hip_get_local_nat_udp_port() : 0),
                        ctx->hadb_entry->peer_udp_port,
                        ctx->output_msg,
@@ -1155,9 +1154,6 @@
     HIP_IFEL(err, -ECOMM, "Sending R2 packet failed.\n");
 
 out_err:
-    if (ctx->output_msg) {
-        free(ctx->output_msg);
-    }
 #ifdef CONFIG_HIP_PERFORMANCE
     HIP_DEBUG("Stop and write PERF_I2\n");
     hip_perf_stop_benchmark(perf_set, PERF_I2);

=== modified file 'hipd/output.h'
--- hipd/output.h       2010-09-03 11:40:19 +0000
+++ hipd/output.h       2010-11-09 16:37:54 +0000
@@ -1,12 +1,5 @@
-/** @file
- * A header file for output.c.
- *
- * @author  Janne Lundberg
- * @author  Miika Komu
- * @author  Mika Kousa
- * @author  Kristian Slavov
- * @author Rene Hummen
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -30,6 +23,15 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
+/**
+ * @file
+ * @author Janne Lundberg
+ * @author Miika Komu
+ * @author Mika Kousa
+ * @author Kristian Slavov
+ * @author Rene Hummen
+ */
+
 #ifndef HIP_HIPD_OUTPUT_H
 #define HIP_HIPD_OUTPUT_H
 

=== modified file 'hipd/pisa.c'
--- hipd/pisa.c 2010-07-07 16:42:17 +0000
+++ hipd/pisa.c 2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This file contains functions that are specific to PISA. They deal with the
  * certificate loading.
  *
@@ -36,6 +37,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "config.h"
 #include "lib/core/debug.h"
 #include "hipd.h"
 #include "pisa.h"
@@ -45,7 +47,7 @@
 static char *midauth_cert = NULL;
 
 /**
- * Load a certificate from the file /etc/hip/cert and store it in memory
+ * Load a certificate from the file HIPL_SYSCONFDIR/cert and store it in memory
  *
  * @return 0 on success
  */
@@ -59,7 +61,7 @@
     midauth_cert = malloc(CERT_MAX_SIZE);
     memset(midauth_cert, 0, CERT_MAX_SIZE);
 
-    if (!(f = fopen("/etc/hip/cert", "r"))) {
+    if (!(f = fopen(HIPL_SYSCONFDIR "/cert", "r"))) {
         HIP_ERROR("Could not open certificate file.\n");
         return -1;
     }

=== modified file 'hipd/pisa.h'
--- hipd/pisa.h 2010-07-04 17:54:18 +0000
+++ hipd/pisa.h 2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This file contains function declarations  specific to PISA. They deal with 
the
  * certificate loading.
  *

=== modified file 'hipd/pkt_handling.c'
--- hipd/pkt_handling.c 2010-09-06 17:06:39 +0000
+++ hipd/pkt_handling.c 2010-11-09 16:37:54 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,11 +21,13 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * @brief Functionality for dynamic packet handling.
  *
  * @author Tim Just <tim.just@xxxxxxxxxxxxxx>
- *
  */
 
 #include <stdint.h>

=== modified file 'hipd/pkt_handling.h'
--- hipd/pkt_handling.h 2010-09-06 17:08:50 +0000
+++ hipd/pkt_handling.h 2010-11-09 16:37:54 +0000
@@ -1,8 +1,5 @@
-/**
- * @file
- * The header file for hipd/pkt_handling.c
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -24,10 +21,13 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * @author Tim Just <tim.just@xxxxxxxxxxxxxx>
- *
  */
+
 #ifndef HIP_HIPD_PKT_HANDLING_H
 #define HIP_HIPD_PKT_HANDLING_H
 

=== modified file 'hipd/registration.c'
--- hipd/registration.c 2010-08-20 16:38:55 +0000
+++ hipd/registration.c 2010-10-27 11:11:20 +0000
@@ -1,6 +1,5 @@
-/** @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -22,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This file defines a registration mechanism for the Host Identity Protocol
  * (HIP) that allows hosts to register with services.
  *
@@ -99,7 +101,7 @@
  */
 static int hip_del_pending_request_by_expiration(void)
 {
-    int index                      = 0;
+    int idx = 0;
     hip_ll_node_t *iter            = NULL;
     hip_pending_request_t *request = NULL;
     time_t now                     = time(NULL);
@@ -110,11 +112,11 @@
         if (now - request->created > HIP_PENDING_REQUEST_LIFETIME) {
             HIP_DEBUG("Deleting and freeing a pending request by " \
                       "expiration (%u seconds) at index %u.\n",
-                      now - request->created, index);
-            hip_ll_del(&pending_requests, index, free);
+                      now - request->created, idx);
+            hip_ll_del(&pending_requests, idx, free);
             return 0;
         }
-        index++;
+        idx++;
     }
 
     return -1;
@@ -240,7 +242,7 @@
  */
 int hip_del_pending_request(hip_ha_t *entry)
 {
-    int index           = 0;
+    int idx = 0;
     hip_ll_node_t *iter = NULL;
 
     /* Iterate through the linked list. The iterator itself can't be used
@@ -250,11 +252,11 @@
     while ((iter = hip_ll_iterate(&pending_requests, iter)) != NULL) {
         if (((hip_pending_request_t *) (iter->ptr))->entry == entry) {
             HIP_DEBUG("Deleting and freeing a pending request at " \
-                      "index %u.\n", index);
-            hip_ll_del(&pending_requests, index, free);
+                      "index %u.\n", idx);
+            hip_ll_del(&pending_requests, idx, free);
             return 0;
         }
-        index++;
+        idx++;
     }
 
     return -1;
@@ -273,7 +275,7 @@
  */
 int hip_del_pending_request_by_type(hip_ha_t *entry, uint8_t reg_type)
 {
-    int index                      = 0;
+    int idx = 0;
     hip_ll_node_t *iter            = NULL;
     hip_pending_request_t *request = NULL;
 
@@ -282,11 +284,11 @@
         request = iter->ptr;
         if (request->entry == entry && request->reg_type == reg_type) {
             HIP_DEBUG("Deleting and freeing a pending request by " \
-                      "type at index %u.\n", index);
-            hip_ll_del(&pending_requests, index, free);
+                      "type at index %u.\n", idx);
+            hip_ll_del(&pending_requests, idx, free);
             return 0;
         }
-        index++;
+        idx++;
     }
 
     return -1;
@@ -1386,7 +1388,7 @@
          * no more parameters left. */
         i          = 0;
         reg_failed = (const struct hip_reg_failed *) hip_get_next_param(msg,
-                                        (const hip_tlv_common_t *) reg_failed);
+                                        (const struct hip_tlv_common 
*)reg_failed);
 
         if (reg_failed == NULL) {
             break;

=== modified file 'hipd/registration.h'
--- hipd/registration.h 2010-07-07 16:42:17 +0000
+++ hipd/registration.h 2010-10-15 15:29:14 +0000
@@ -1,12 +1,5 @@
-/** @file
- * A header file for registration.c.
- *
- * @author  Lauri Silvennoinen
- * @version 1.0
- * @date    20.05.2008
- * @note    Related RFC: <a href="http://www.rfc-editor.org/rfc/rfc5203.txt";>
- *          Host Identity Protocol (HIP) Registration Extension</a>
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -28,6 +21,15 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file
+ * @author  Lauri Silvennoinen
+ * @version 1.0
+ * @date    20.05.2008
+ * @note    Related RFC: <a href="http://www.rfc-editor.org/rfc/rfc5203.txt";>
+ *          Host Identity Protocol (HIP) Registration Extension</a>
  * @see     registration.c
  * @see     hiprelay.h
  * @see     escrow.h

=== modified file 'hipd/user.c'
--- hipd/user.c 2010-09-03 11:56:17 +0000
+++ hipd/user.c 2010-11-09 16:37:54 +0000
@@ -1,6 +1,5 @@
-/** @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -22,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This file defines a user message (i.e. message from hipconf or hipfw) 
processing.
  * The interface sends a response message back if the sender requested one. See
  * lib/core/message.c for the details.
@@ -207,7 +209,6 @@
  *       switch(msg_type) block in this function.
  * @param  msg  a pointer to the received user message HIP packet.
  * @param  src the origin of the sender
- * @param  send_response response
  * @return zero on success, or negative error value on error.
  */
 int hip_handle_user_msg(hip_common_t *msg,

=== modified file 'hipd/user.h'
--- hipd/user.h 2010-08-25 09:06:43 +0000
+++ hipd/user.h 2010-10-15 15:29:14 +0000
@@ -1,12 +1,5 @@
-/** @file
- * A header file for user.c.
- *
- * @author  Miika Komu <miika_iki.fi>
- * @author  Kristian Slavov <kslavov_hiit.fi>
- * @author  Bing Zhou <bingzhou_cc.hut.fi>
- * @author  Tao Wan <taow_cc.hut.fi>
- * @author  Rene Hummen
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -30,6 +23,15 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
+/**
+ * @file
+ * @author  Miika Komu <miika_iki.fi>
+ * @author  Kristian Slavov <kslavov_hiit.fi>
+ * @author  Bing Zhou <bingzhou_cc.hut.fi>
+ * @author  Tao Wan <taow_cc.hut.fi>
+ * @author  Rene Hummen
+ */
+
 #ifndef HIP_HIPD_USER_H
 #define HIP_HIPD_USER_H
 

=== modified file 'lib/core/builder.c'
--- lib/core/builder.c  2010-09-03 11:56:17 +0000
+++ lib/core/builder.c  2010-11-09 16:37:54 +0000
@@ -1,6 +1,5 @@
-/** @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -22,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This file defines building and parsing functions for Host Identity
  * Protocol (HIP) kernel module and user messages. The functions can
  * be used for sending on-the-wire HIP control messages to the
@@ -614,11 +616,11 @@
 
 /**
  * hip_check_userspace_param_type - check the userspace parameter type
- * @param UNUSED pointer to the parameter
+ * @param param pointer to the parameter
  *
  * @return 1 if parameter type is valid, or 0 if parameter type is invalid
  */
-static int hip_check_userspace_param_type(const struct hip_tlv_common *param 
UNUSED)
+static int hip_check_userspace_param_type(UNUSED const struct hip_tlv_common 
*param)
 {
     return 1;
 }
@@ -2906,7 +2908,7 @@
 
 /**
  * hip_build_param_esp_info - build esp_info parameter
- * \todo Properly comment parameters of hip_build_param_esp_info()
+ * @todo Properly comment parameters of hip_build_param_esp_info()
  *
  * @param msg the message where the parameter will be appended
  * @param keymat_index no desription
@@ -3728,7 +3730,7 @@
     int amount                  = 0;
     uint8_t type;
 
-    while(address_pointer <
+    while (address_pointer <
           ((const char *) locator) + hip_get_param_contents_len(locator)) {
         type = ((const struct hip_locator_info_addr_item *)
                address_pointer)->locator_type;

=== modified file 'lib/core/builder.h'
--- lib/core/builder.h  2010-09-03 11:40:19 +0000
+++ lib/core/builder.h  2010-11-09 16:37:54 +0000
@@ -1,11 +1,5 @@
-/** @file
- * A header file for builder.c.
- *
- * @author  Miika Komu <miika_iki.fi>
- * @author  Mika Kousa <mkousa_iki.fi>
- * @author  Tobias Heer <heer_tobibox.de>
- * @version 1.0
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -29,6 +23,14 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
+/**
+ * @file
+ * @author  Miika Komu <miika_iki.fi>
+ * @author  Mika Kousa <mkousa_iki.fi>
+ * @author  Tobias Heer <heer_tobibox.de>
+ * @version 1.0
+ */
+
 #ifndef HIP_LIB_CORE_BUILDER_H
 #define HIP_LIB_CORE_BUILDER_H
 

=== modified file 'lib/core/capability.c'
--- lib/core/capability.c       2010-07-28 12:34:55 +0000
+++ lib/core/capability.c       2010-10-18 17:44:31 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,6 +21,13 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file
+ * @brief Functionality to lower the privileges of a daemon
+ *
+ * @author Miika Komu <miika@xxxxxx>
  *
  * This file contains functionality to lower the privileges (or
  * capabilities) of hipd and hipfw. It is important to restrict
@@ -30,10 +35,6 @@
  * specific.
  *
  * This code causes problems with valgrind, because of setpwent(3).
- *
- * @brief Functionality to lower the privileges of a daemon
- *
- * @author Miika Komu <miika@xxxxxx>
  */
 
 #define _BSD_SOURCE

=== modified file 'lib/core/capability.h'
--- lib/core/capability.h       2010-07-04 17:54:18 +0000
+++ lib/core/capability.h       2010-10-15 15:29:14 +0000
@@ -1,8 +1,5 @@
-/** @file
- * The header for capability.c.
- *
- * @author  Tobias Heer  <heer@xxxxxxxxxxxxxxxxx> (header file only)
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'lib/core/certtools.c'
--- lib/core/certtools.c        2010-08-29 16:24:14 +0000
+++ lib/core/certtools.c        2010-10-18 17:44:31 +0000
@@ -1,6 +1,5 @@
-/** @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -22,10 +21,12 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This file defines the certificate building and verification functions to 
use with HIP
  *
- *
  * @author Samu Varjonen
  */
 
@@ -274,7 +275,8 @@
         memset(y_bin, 0, (stop - start + 1));
         snprintf((char *) y_b64, (stop - start - 1), "%s", 
&cert->public_key[start + 1]);
         evpret = EVP_DecodeBlock(y_bin, y_b64, strlen((char *) y_b64));
-    } else {HIP_IFEL((1 == 0), -1, "Unknown algorithm\n");
+    } else {
+        HIP_IFEL((1 == 0), -1, "Unknown algorithm\n");
     }
 
     memset(sha_digest, '\0', sizeof(sha_digest));
@@ -340,7 +342,8 @@
         /* DSA_do_verify returns 1 if success. */
         cert->success = err == 1 ? 0 : -1;
         HIP_IFEL((err = err == 1 ? 0 : -1), -1, "DSA_do_verify error\n");
-    } else {HIP_IFEL((1 == 0), -1, "Unknown algorithm\n");
+    } else {
+        HIP_IFEL((1 == 0), -1, "Unknown algorithm\n");
     }
 
 out_err:
@@ -437,7 +440,7 @@
 }
 
 /**
- * Function to build the create minimal SPKI cert
+ * Function to build the create minimal SPKI cert (plus socket parameter)
  *
  * @param content holds the struct hip_cert_spki_info containing
  *                the minimal needed information for cert object,
@@ -449,13 +452,17 @@
  * @param subject HIT in representation encoding 2001:001...
  * @param not_before time in timeval before which the cert should not be used
  * @param not_after time in timeval after which the cert should not be used
- *
+ * @param hip_user_socket socket, already connected to hipd, to pass through to
+ *                hip_send_recv_daemon_info
  * @return 0 if ok -1 if error
  */
-int hip_cert_spki_create_cert(struct hip_cert_spki_info *content,
-                              const char *issuer_type, struct in6_addr *issuer,
-                              const char *subject_type, struct in6_addr 
*subject,
-                              time_t *not_before, time_t *not_after)
+int hip_cert_spki_create_cert_sock(struct hip_cert_spki_info *content,
+                                   const char *issuer_type,
+                                   struct in6_addr *issuer,
+                                   const char *subject_type,
+                                   struct in6_addr *subject,
+                                   time_t *not_before, time_t *not_after,
+                                   int hip_user_socket)
 {
     int err           = 0;
     char *tmp_issuer  = NULL;
@@ -559,7 +566,7 @@
     /* send and wait */
     HIP_DEBUG("Sending request to sign SPKI cert sequence to "
               "daemon and waiting for answer\n");
-    hip_send_recv_daemon_info(msg, 0, 0);
+    hip_send_recv_daemon_info(msg, 0, hip_user_socket);
 
     /* get the struct from the message sent back by the daemon */
     HIP_IFEL(!(returned = hip_get_param(msg, HIP_PARAM_CERT_SPKI_INFO)),
@@ -588,6 +595,31 @@
 }
 
 /**
+ * Function to build the create minimal SPKI cert
+ *
+ * @param content holds the struct hip_cert_spki_info containing
+ *                the minimal needed information for cert object,
+ *                also contains the char table where the cert object
+ *                is to be stored
+ * @param issuer_type With HIP its HIT
+ * @param issuer HIT in representation encoding 2001:001...
+ * @param subject_type With HIP its HIT
+ * @param subject HIT in representation encoding 2001:001...
+ * @param not_before time in timeval before which the cert should not be used
+ * @param not_after time in timeval after which the cert should not be used
+ * @return 0 if ok -1 if error
+ */
+int hip_cert_spki_create_cert(struct hip_cert_spki_info *content,
+                              const char *issuer_type, struct in6_addr *issuer,
+                              const char *subject_type, struct in6_addr 
*subject,
+                              time_t *not_before, time_t *not_after)
+{
+   return hip_cert_spki_create_cert_sock(content, issuer_type, issuer,
+                                         subject_type, subject, not_before,
+                                         not_after, 0);
+}
+
+/**
  * Function that takes the cert in single char table and constructs
  * hip_cert_spki_info from it
  *
@@ -767,7 +799,8 @@
     err = hip_get_msg_err(msg);
     if (err == 0) {
         HIP_DEBUG("Verified successfully\n");
-    } else {      HIP_DEBUG("Verification failed\n");
+    } else {
+        HIP_DEBUG("Verification failed\n");
     }
 
 out_err:

=== modified file 'lib/core/certtools.h'
--- lib/core/certtools.h        2010-07-14 16:01:50 +0000
+++ lib/core/certtools.h        2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -25,15 +23,13 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
-/** @file
- * A header file for certtools.c
- *
+/**
+ * @file
  * Certificate building, parseing and verification functions.
  *
  * @author Samu Varjonen
  * @version 0.1
  * @date 31.3.2008
- *
  */
 
 #ifndef HIP_LIB_CORE_CERTTOOLS_H
@@ -45,12 +41,11 @@
 #include <openssl/x509.h>
 #include <sys/types.h>
 
-#include "hashtable.h"
 #include "protodefs.h"
 
 
 /** Defines */
-#define HIP_CERT_CONF_PATH HIPL_SYSCONFDIR "hip_cert.cnf"
+#define HIP_CERT_CONF_PATH HIPL_SYSCONFDIR "/hip_cert.cnf"
 
 /* Needed if the configuration file for certs did not exist  */
 #define HIP_CERT_INIT_DAYS 10
@@ -71,11 +66,14 @@
 
 /** SPKI cert related functions */
 int hip_cert_spki_lib_verify(struct hip_cert_spki_info *);
+int hip_cert_spki_create_cert_sock(struct hip_cert_spki_info *,
+                              const char *, struct in6_addr *,
+                              const char *, struct in6_addr *,
+                              time_t *, time_t *, int);
 int hip_cert_spki_create_cert(struct hip_cert_spki_info *,
                               const char *, struct in6_addr *,
                               const char *, struct in6_addr *,
                               time_t *, time_t *);
-int hip_cert_spki_construct_keys(HIP_HASHTABLE *, hip_hit_t *, RSA *);
 int hip_cert_spki_char2certinfo(char *, struct hip_cert_spki_info *);
 int hip_cert_spki_send_to_verification(struct hip_cert_spki_info *);
 

=== modified file 'lib/core/common.h'
--- lib/core/common.h   2010-09-03 11:56:17 +0000
+++ lib/core/common.h   2010-11-09 16:37:54 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * @author: Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
  * @author  Mircea Gherzan <mircea.gherzan@xxxxxxxxxxxxxx>
  */

=== modified file 'lib/core/conf.c'
--- lib/core/conf.c     2010-08-25 11:43:43 +0000
+++ lib/core/conf.c     2010-11-06 15:23:19 +0000
@@ -1,6 +1,5 @@
-/** @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -22,10 +21,13 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This library is used to configure HIP daemon (hipd) dynamically
  * with the hipconf command line tool. Hipd uses this library also to
- * parse the static configuration from @c /etc/hip/hipd_config (the file
+ * parse the static configuration from @c HIPL_SYSCONFDIR/hipd_config (the file
  * has same syntax as hipconf).
  *
  * All new messages have to be registered into the action_handler
@@ -189,13 +191,13 @@
 
 /**
  * A help string containing the usage of @c hipconf and also
- * @c /etc/hip/hipd_config.
+ * @c HIPL_SYSCONFDIR/hipd_config.
  *
  * @note If you added a new action, do not forget to add a brief usage below
  *       for the action.
  */
 const char *hipconf_usage =
-    "add|del map <hit> <ipv6> [lsi]\n"
+    "add|del map <hit> <ip> [lsi]\n"
     "del hi <hit>|all\n"
     "get hi default|all\n"
     "new|add hi anon|pub rsa|dsa filebasename\n"
@@ -870,7 +872,6 @@
     int index_of_hit = 0, index_of_ip = 0, opp_mode = 0;;
     uint8_t lifetime             = 0, *reg_types = NULL;
     time_t seconds_from_lifetime = 0;
-    char lowercase[30];
 
     memset(&hit, 0, sizeof(hit));
     memset(&ipv6, 0, sizeof(ipv6));
@@ -881,6 +882,8 @@
         err = -1;
         goto out_err;
     } else if (action == ACTION_ADD) {
+        char *tail_ptr = NULL;
+
         if (optc < 4) {
             if (optc < 3) {
                 HIP_ERROR("Missing arguments.\n");
@@ -901,20 +904,12 @@
             index_of_ip        = optc - 2;
         }
 
-        HIP_IFEL(hip_string_is_digit(opt[optc - 1]), -1,
+        seconds = strtoul(opt[optc - 1], &tail_ptr, 10);
+        HIP_IFEL(*tail_ptr == '\0' && seconds > 0 && seconds <= 15384774, -1,
                  "Invalid lifetime value \"%s\" given.\n"       \
                  "Please give a lifetime value between 1 and "  \
                  "15384774 seconds.\n", opt[optc - 1]);
 
-        seconds = atoi(opt[optc - 1]);
-
-        if (seconds <= 0 || seconds > 15384774) {
-            HIP_ERROR("Invalid lifetime value \"%s\" given.\n"    \
-                      "Please give a lifetime value between 1 and " \
-                      "15384774 seconds.\n", opt[optc - 1]);
-            goto out_err;
-        }
-
         HIP_IFEL(hip_get_lifetime_value(seconds, &lifetime), -1,
                  "Unable to convert seconds to a lifetime value.\n");
 
@@ -992,19 +987,18 @@
             goto out_err;
         }
 
-        hip_string_to_lowercase(lowercase, opt[i], strlen(opt[i]) + 1);
-        if (strcmp("rvs", lowercase) == 0) {
+        if (strcasecmp("rvs", opt[i]) == 0) {
             reg_types[i] = HIP_SERVICE_RENDEZVOUS;
-        } else if (strcmp("relay", lowercase) == 0) {
+        } else if (strcasecmp("relay", opt[i]) == 0) {
             reg_types[i] = HIP_SERVICE_RELAY;
-        } else if (strcmp("full-relay", lowercase) == 0)  {
+        } else if (strcasecmp("full-relay", opt[i]) == 0)  {
             reg_types[i] = HIP_SERVICE_FULLRELAY;
         }         /* To cope with the atoi() error value we handle the 'zero'
                    * case here. */
-        else if (strcmp("0", lowercase) == 0) {
+        else if (strcasecmp("0", opt[i]) == 0) {
             reg_types[i] = 0;
         } else {
-            reg_type = atoi(lowercase);
+            reg_type = atoi(opt[i]);
             if (reg_type <= 0 || reg_type > 255) {
                 HIP_ERROR("'%s' is not a valid service name " \
                           "or service number.\n", opt[i]);
@@ -1205,13 +1199,13 @@
 
     HIP_IFEL((optc != 2 && optc != 3), -1, "Missing arguments\n");
 
-    HIP_IFEL(convert_string_to_address(opt[0], &hit), -1,
-             "string to address conversion failed\n");
-
-    HIP_IFEL((err = convert_string_to_address(opt[1], &ip6)), -1,
-             "string to address conversion failed\n");
-
-    if ((err && !convert_string_to_address_v4(opt[1], &aux))) {
+    HIP_IFEL(hip_convert_string_to_address(opt[0], &hit), -1,
+             "string to address conversion failed\n");
+
+    HIP_IFEL((err = hip_convert_string_to_address(opt[1], &ip6)), -1,
+             "string to address conversion failed\n");
+
+    if ((err && inet_pton(AF_INET, opt[1], &aux) != 1)) {
         HIP_IFEL(IS_LSI32(aux.s_addr), -1, "Missing ip address before lsi\n");
     }
 
@@ -1241,7 +1235,7 @@
              "build param hit failed\n");
 
     if (optc == 3) {
-        HIP_IFEL(convert_string_to_address_v4(opt[2], &lsi), -1,
+        HIP_IFEL(inet_pton(AF_INET, opt[2], &lsi) != 1, -1,
                  "string to address conversion failed\n");
         HIP_IFEL(!IS_LSI32(lsi.s_addr), -1, "Wrong LSI value\n");
         HIP_IFEL(hip_build_param_contents(msg, &lsi,
@@ -1833,10 +1827,10 @@
 {
     int err = 0;
     hip_hit_t hit;
-    const hip_tlv_common_t *param;
     const hip_lsi_t *lsi;
     char lsi_str[INET_ADDRSTRLEN];
     const char *hit_str = opt[0];
+    const struct hip_tlv_common *param;
 
     HIP_IFEL((inet_pton(AF_INET6, hit_str, &hit) <= 0), 1,
              "Not an IPv6 address\n");
@@ -2009,7 +2003,7 @@
         if (!strcmp("all", opt[0])) {
             hip_conf_print_info_ha(ha);
         } else {
-            HIP_IFE(convert_string_to_address(opt[0], &hit1), -1);
+            HIP_IFE(hip_convert_string_to_address(opt[0], &hit1), -1);
 
             if ((ipv6_addr_cmp(&hit1, &ha->hit_our) == 0) ||
                 (ipv6_addr_cmp(&hit1, &ha->hit_peer) == 0))
@@ -2229,7 +2223,7 @@
                 free(libs[i]);
         }
         for (k = 0; 0 < argc; k++) {
-            if(argv_new[k]) {
+            if (argv_new[k]) {
                 free(argv_new[k]);
             }
         }

=== modified file 'lib/core/conf.h'
--- lib/core/conf.h     2010-08-10 08:21:47 +0000
+++ lib/core/conf.h     2010-10-15 15:29:14 +0000
@@ -1,16 +1,5 @@
-/** @file
- * A header file for conf.c
- *
- * @author  Janne Lundberg <jlu_tcs.hut.fi>
- * @author  Miika Komu <miika_iki.fi>
- * @author  Mika Kousa <mkousa_cc.hut.fi>
- * @author  Anthony D. Joseph <adj_hiit.fi>
- * @author  Abhinav Pathak <abhinav.pathak_hiit.fi>
- * @author  Bing Zhou <bingzhou_cc.hut.fi>
- * @author  Anu Markkola
- * @author  Lauri Silvennoinen
- * @author  Tao Wan <twan@xxxxxxxxx>
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -34,6 +23,19 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
+/**
+ * @file
+ * @author  Janne Lundberg <jlu_tcs.hut.fi>
+ * @author  Miika Komu <miika_iki.fi>
+ * @author  Mika Kousa <mkousa_cc.hut.fi>
+ * @author  Anthony D. Joseph <adj_hiit.fi>
+ * @author  Abhinav Pathak <abhinav.pathak_hiit.fi>
+ * @author  Bing Zhou <bingzhou_cc.hut.fi>
+ * @author  Anu Markkola
+ * @author  Lauri Silvennoinen
+ * @author  Tao Wan <twan@xxxxxxxxx>
+ */
+
 #ifndef HIP_LIB_CORE_CONF_H
 #define HIP_LIB_CORE_CONF_H
 

=== modified file 'lib/core/crypto.c'
--- lib/core/crypto.c   2010-07-14 15:58:20 +0000
+++ lib/core/crypto.c   2010-10-18 17:44:31 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * HIP crypto management functions using OpenSSL.  Includes
  * Diffie-Hellman groups and shared key generation, DSA/RSA key
  * creation and disk storage, signing, verifying and HMAC creation.

=== modified file 'lib/core/crypto.h'
--- lib/core/crypto.h   2010-07-14 16:01:50 +0000
+++ lib/core/crypto.h   2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -65,8 +63,8 @@
 #define DSA_KEY_DEFAULT_BITS       1024
 #define RSA_KEY_DEFAULT_BITS       1024
 
-#define DEFAULT_HOST_DSA_KEY_FILE_BASE "hip_host_dsa_key"
-#define DEFAULT_HOST_RSA_KEY_FILE_BASE "hip_host_rsa_key"
+#define DEFAULT_HOST_DSA_KEY_FILE_BASE "/hip_host_dsa_key"
+#define DEFAULT_HOST_RSA_KEY_FILE_BASE "/hip_host_rsa_key"
 #define DEFAULT_PUB_FILE_SUFFIX        ".pub"
 
 #define DEFAULT_PUB_HI_FILE_NAME_SUFFIX  "_pub"

=== modified file 'lib/core/debug.c'
--- lib/core/debug.c    2010-08-29 16:24:14 +0000
+++ lib/core/debug.c    2010-10-18 17:44:31 +0000
@@ -1,11 +1,5 @@
-/**
- * @file
- * Debugging functions for HIPL userspace applications. Production of quality
- * code prints debugging stuff via syslog, testing code prints interactively on
- * stderr. This is done automatically using DEBUG flag in Makefile (see logtype
- * variable below).
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -27,7 +21,14 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
+ * Debugging functions for HIPL userspace applications. Production of quality
+ * code prints debugging stuff via syslog, testing code prints interactively on
+ * stderr. This is done automatically using DEBUG flag in Makefile (see logtype
+ * variable below).
  * Examples:
  *<pre>
  * HIP_INFO("test foobar");
@@ -373,6 +374,214 @@
 }
 
 /**
+ * Convert a 4-bit value to a hexadecimal string representation.
+ *
+ * @param q     the 4-bit value (an integer between 0 and 15) to convert to 
hex.
+ * @return      1 byte of hexadecimal output as a string character.
+ */
+static char hip_quad2hex(const char q)
+{
+    HIP_ASSERT(q < 16);
+
+    if (q < 10) {
+        return '0' + q;
+    } else {
+        return 'A' + (q - 10);
+    }
+}
+
+/**
+ * Convert a single byte to a hexadecimal string representation.
+ *
+ * @param c     the byte to convert to hex.
+ * @param bfr   the buffer to write the 2 bytes of hexadecimal output to.
+ */
+static void hip_byte2hex(const char c, char* bfr)
+{
+    const int high_quad = (c & 0xF0) >> 4;
+    const int low_quad = c & 0x0F;
+    *bfr = hip_quad2hex(high_quad);
+    *(bfr + 1) = hip_quad2hex(low_quad);
+}
+
+/**
+ * Write the hexadecimal string representation of a memory area to a buffer.
+ * At most @a in_len bytes of the input memory are read and at most @a out_len 
bytes of the output buffer are written, whichever comes first.
+ * If at least one byte was converted, the hexadecimal representation is 
terminated by 0.
+ * If the memory regions of @a in and @a out overlap, the result of the 
operation is undefined.
+ *
+ * @param in        the address of the start of the memory area to convert.
+ * @param in_len    the size in bytes of the memory area to convert.
+ * @param out       the address of the buffer to write the hexadecimal 
representation to.
+ * @param out_len   the size in bytes of the out buffer to write to.
+ * @return          the number of bytes from in that were converted.
+ */
+static size_t hip_mem2hex(const void* in, const size_t in_len, char* out, 
const size_t out_len)
+{
+    if (in_len > 0 && out_len > 2) {
+        const unsigned char* in_cur = in;
+        const unsigned char* in_end = in_cur + in_len;
+        char* out_cur = out;
+        const char* out_end = out_cur + out_len;
+
+        // terminate if either we reach the end of in or if there is not 
enough room to write another hex digit and the terminating 0 into out.
+        while (in_cur < in_end && out_cur <= (out_end - 3)) {
+            hip_byte2hex(*in_cur, out_cur);
+
+            in_cur += 1;
+            out_cur += 2;
+        }
+
+        *out_cur = '\0';
+
+        return (in_cur - (const unsigned char*)in);
+    } else {
+        return 0;
+    }
+}
+
+/**
+ * Convert a byte to its printable ASCII representation (e.g. the numeric 
value 65 is converted to 'A').
+ * If it is not printable, convert it to '.'.
+ *
+ * @param b the byte to convert.
+ * @return  the printable ASCII representation of @a b
+ */
+static char hip_byte2printable(const char b)
+{
+    if (b >= 32 && b <= 126) {
+        return b;
+    } else {
+        return '.';
+    }
+}
+
+static const unsigned int HIP_MEM2PRETTY_HEX_INPUT_LINE_LENGTH = 16;
+static const unsigned int HIP_MEM2PRETTY_HEX_OUTPUT_LINE_LENGTH = (16 
/*HIP_MEM2PRETTY_HEX_INPUT_LINE_LENGTH*/ * 4) + 1;
+
+/**
+ * Retrieve the amount of buffer space necessary to hold the pretty printed 
output produced by hip_mem2pretty_hex().
+ *
+ * @param in_len    the size of the memory area to convert with 
hip_mem2pretty_hex()
+ * @return          the number of bytes of the hip_mem2pretty_hex() output.
+ */
+static size_t hip_mem2pretty_hex_size(const size_t in_len)
+{
+    // for each line, i.e., multiple of 16 input bytes (including partial 
ones):
+    // 32 bytes for hex digits, 16 bytes for spaces, 16 bytes for ascii, 1 
line == 65 bytes
+    // plus terminating 0 character
+    const size_t full_lines = in_len / 16;
+    const size_t partial_lines = (in_len % 16) != 0 ? 1 : 0;
+    return ((full_lines + partial_lines) * 
HIP_MEM2PRETTY_HEX_OUTPUT_LINE_LENGTH) + 1;
+}
+
+/**
+ * Create one line of a pretty-printed hexadecimal string representation of a 
memory area in the format of the hexdump -C UNIX command to a buffer.
+ * At most @a in_len bytes of the memory are read and at most @a out_len bytes 
are are written, whichever comes first.
+ * The function always writes a full line of 
HIP_MEM2PRETTY_HEX_OUTPUT_LINE_LENGTH bytes including a newline character into 
out.
+ * If the memory regions of @a in and @a out overlap, the result of the 
operation is undefined.
+ *
+ * Example of the output:
+ * <pre>
+ * 13 88 94 64 0d b9 89 ff f3 cc 4c a1 80 11 05 94 ...d......L.....
+ * </pre>
+ *
+ * @param in        the address of the start of the memory area to convert.
+ * @param in_len    the size in bytes of the memory area to convert. At most 
HIP_MEM2PRETTY_HEX_INPUT_LINE_LENGTH bytes are read.
+ * @param out       the address of the buffer to write the hexadecimal 
representation to. Exactly HIP_MEM2PRETTY_HEX_OUTPUT_LINE_LENGTH are written.
+ * @param out_len   the size in bytes of the out buffer to write to. This 
value should be greater or equal to HIP_MEM2PRETTY_HEX_OUTPUT_LINE_LENGTH.
+ * @return          1 if a line of output was written to out. 0 and no output 
is written if @a in_len is 0 or if @a out_len is less than 
HIP_MEM2PRETTY_HEX_OUTPUT_LINE_LENGTH.
+ */
+static int hip_mem2pretty_hex_line(const char* in, const size_t in_len, char* 
out, const size_t out_len)
+{
+    if (in_len > 0 && out_len >= HIP_MEM2PRETTY_HEX_OUTPUT_LINE_LENGTH) {
+        const char* in_cur = in; // incremented with every fully processed 
input byte
+        const char* in_end = in_cur + in_len; // the final input byte + 1, 
i.e., the first not to read from
+        const char* in_line_end = in_cur + 
HIP_MEM2PRETTY_HEX_INPUT_LINE_LENGTH; // the input byte to iterate 'in_cur' up 
to
+        char* hex = out;
+        char* ascii = out + HIP_MEM2PRETTY_HEX_INPUT_LINE_LENGTH * 3;
+
+        // write hex and ascii representations
+        while (in_cur < in_line_end) {
+            // is there still input data available?
+            if (in_cur < in_end) {
+                // convert input
+                hip_byte2hex(*in_cur, hex);  // add hex digits
+                *ascii = hip_byte2printable(*in_cur);    // add printable char
+            } else {
+                // write dummy output
+                *hex = ' ';
+                *(hex + 1) = ' ';
+                *ascii = ' ';
+            }
+
+            *(hex + 2) = ' ';   // add space between hex digits
+            hex += 3;   // move to next hex digit position
+            ascii += 1; // move to next ascii position
+            in_cur += 1; // move to next input byte (it's okay to increment 
this even if in_cur >= in_end because in that case we do not read from this 
pointer)
+        }
+
+        // at this point, we have written a full line and ascii points to its 
end - add a newline.
+        *ascii = '\n';
+
+        return 1;
+    } else {
+        return 0;
+    }
+}
+
+/**
+ * Write a pretty-printed hexadecimal string representation of a memory area 
in the format of the hexdump -C UNIX command to a buffer.
+ * At most @a in_len bytes of the memory are read and at most @a out_len bytes 
are are written, whichever comes first.
+ * If at least one byte was converted, the hexadecimal representation is 
terminated by a null character.
+ * If the memory regions of @a in and @a out overlap, the result of the 
operation is undefined.
+ *
+ * Example of the output:
+ * <pre>
+ * 13 88 94 64 0d b9 89 ff f3 cc 4c a1 80 11 05 94 ...d......L.....
+ * 6c 3c 00 00 01 01 08 0a 00 10 a2 58 00 0f 98 30 l<.........X....
+ * </pre>
+ *
+ * @param in        the address of the start of the memory area to convert.
+ * @param in_len    the size in bytes of the memory area at @a in to convert.
+ * @param out       the address of the buffer to write the hexadecimal 
representation to.
+ * @param out_len   the size in bytes of the @a out buffer to write to.
+ * @return          the number of bytes from @a in that were converted.
+ */
+static size_t hip_mem2pretty_hex(const void* in, const size_t in_len, char* 
out, const size_t out_len)
+{
+    // Points to where the input for the next line is to be read from. 
Incremented by HIP_MEM2PRETTY_HEX_INPUT_LINE_LENGTH with every line.
+    const char* in_cur = in;
+    // Points to where the next line of output is to be written to. 
Incremented by HIP_MEM2PRETTY_HEX_OUTPUT_LINE_LENGTH with every line.
+    char* out_cur = out;
+    // Points to the final input byte + 1, i.e., the first input byte not to 
read from.
+    const char* in_end = in_cur + in_len;
+    // Points to the final output byte + 1, i.e., the first output byte not to 
write to.
+    const char* out_end = out_cur + out_len;
+
+    // Iterate while there is still input to read and enough room for another 
full line including the terminating null character.
+    while (in_cur < in_end && out_cur <= (out_end - 
(HIP_MEM2PRETTY_HEX_OUTPUT_LINE_LENGTH + 1))) {
+        const size_t in_remaining = in_len - (in_cur - (const char*)in);
+        const size_t out_remaining = out_len - (out_cur - (const char*)out);
+
+        // convert one line of input
+        const int line_result = hip_mem2pretty_hex_line(in_cur, in_remaining, 
out_cur, out_remaining);
+        // since the loop condition already makes sure that the input to 
hip_mem2pretty_hex_line() is valid, it must return 1.
+        HIP_ASSERT(line_result == 1);
+
+        // advance input pointer by at most the maximum available input so the 
return value is calculated correctly
+        in_cur += (in_remaining > HIP_MEM2PRETTY_HEX_INPUT_LINE_LENGTH ? 
HIP_MEM2PRETTY_HEX_INPUT_LINE_LENGTH : in_remaining);
+        out_cur += HIP_MEM2PRETTY_HEX_OUTPUT_LINE_LENGTH;
+    }
+
+    if (out_cur < out_end) {
+        *out_cur = '\0';
+    }
+
+    return in_cur - (const char*)in;
+}
+
+/**
  * Print raw hexdump starting from address @c str of length @c len. Do not call
  * this function from the outside of the debug module, use the HIP_HEXDUMP 
macro
  * instead.
@@ -385,51 +594,19 @@
  * @param len      the length of the data to be hexdumped
  */
 void hip_hexdump(const char *file, int line, const char *function,
-                 const char *prefix, const void *str, int len)
+                 const char *prefix, const void *str, const size_t len)
 {
-    int hexdump_max_size = 0;
-    int hexdump_count    = 0;
-    char *hexdump        = NULL;
-    int hexdump_written  = 0;
-    int hexdump_index    = 0;
-    int char_index       = 0;
-
-    hexdump_max_size = len * 2 + 1;
-    hexdump_count    = hexdump_max_size;
-
-    hexdump          = calloc(hexdump_max_size, sizeof(char));
-    if (hexdump == NULL) {
-        HIP_DIE("hexdump memory allocation failed\n");
-    }
-    if (len == 0) {
-        /* Removed this error message to keep hexdump quiet in
-         * HIP_DUMP_MSG for zero length padding. Lauri 22.09.2006 */
-        //HIP_ERROR("hexdump length was 0\n");
-    } else {
-        do {
-            /* note: if you change the printing format, adjust also 
hexdump_count! */
-            hexdump_written
-                    = snprintf((char *) (hexdump + hexdump_index),
-                               hexdump_count,
-                               "%02x",
-                               (unsigned char) (*(((const unsigned char *) str)
-                                       + char_index)));
-            if (hexdump_written < 0 || hexdump_written > hexdump_max_size - 1) 
{
-                free(hexdump);
-                HIP_DIE("hexdump msg too long(%d)", hexdump_written);
-            } else {
-                hexdump_count -= hexdump_written;
-                HIP_ASSERT(hexdump_count >= 0);
-                hexdump_index += hexdump_written;
-                HIP_ASSERT(hexdump_index + hexdump_count == hexdump_max_size);
-            }
-            char_index++;
-        } while (char_index < len);
-
-        hip_print_str(DEBUG_LEVEL_DEBUG, file, line, function, "%s0x%s\n", 
prefix, hexdump);
-    }
-
-    free(hexdump);
+    if (len > 0) {
+        const size_t buffer_size = (len * 2) + 1;
+        char* buffer = malloc(buffer_size);
+        if (buffer != NULL) {
+            hip_mem2hex(str, len, buffer, buffer_size);
+            hip_print_str(DEBUG_LEVEL_DEBUG, file, line, function, "%s0x%s\n", 
prefix, buffer);
+            free(buffer);
+        } else {
+            HIP_DIE("memory allocation failed\n");
+        }
+    }
 }
 
 /**
@@ -450,125 +627,20 @@
  * @param str      pointer to the beginning of the data to be hexdumped
  * @param len      the length of the data to be hexdumped
  */
-int hip_hexdump_parsed(const char *file, int line, const char *function,
-                       const char *prefix, const void *str, int len)
+void hip_hexdump_parsed(const char *file, int line, const char *function,
+                        const char *prefix, const void *str, const size_t len)
 {
-    int hexdump_total_size = 0;
-    int hexdump_count      = 0;
-    int hexdump_written    = 0;
-    int hexdump_index      = 0;
-    int char_index         = 0;
-    char *hexdump          = NULL;
-
-    int bytes_per_line     = 16;
-    char space             = ' ';
-    char nonascii          = '.';
-    char *asciidump        = NULL;
-    int lines              = 0;
-    int line_index         = 0;
-
-    int pad_length         = 0;
-    int pad_start_position = 0;
-
-    // Count lines
-    if (len % 16 == 0) {
-        lines = (int) len / 16;
-    } else {
-        lines = (int) len / 16 + 1;
-    }
-
-    // one byte requires 4 bytes in the output (two for hex, one for ascii and 
one space)
-    hexdump_total_size = lines * 4 * bytes_per_line + 1;
-    pad_start_position = len * 3 + ((lines - 1) * bytes_per_line) + 1;
-    hexdump_count      = hexdump_total_size;
-    pad_length         = (hexdump_total_size - bytes_per_line) - 
pad_start_position;
-
-    hexdump            = calloc(hexdump_total_size, sizeof(char));
-    asciidump          = calloc((bytes_per_line + 2), sizeof(char));
-
-    if (hexdump == NULL || asciidump == NULL) {
-        HIP_DIE("memory allocation failed\n");
-    }
-
     if (len > 0) {
-        while (char_index < len) {
-            // Write the character in hex
-            hexdump_written = snprintf((char *) (hexdump + hexdump_index),
-                                       hexdump_count, "%02x",
-                                       (unsigned char) (*(((const unsigned 
char *) str) + char_index)));
-            if (hexdump_written < 0 || hexdump_written > hexdump_total_size - 
1) {
-                free(hexdump);
-                HIP_DIE("hexdump msg too long(%d)", hexdump_written);
-            }
-            char written = (unsigned char) (*(((const unsigned char *) str) + 
char_index));
-
-            // Write space between
-            hexdump_index  += hexdump_written;
-            hexdump_count  -= hexdump_written;
-            hexdump_written = snprintf((char *) (hexdump + hexdump_index),
-                                       hexdump_count, "%c", space);
-            if (hexdump_written < 0 || hexdump_written > hexdump_total_size - 
1) {
-                free(hexdump);
-                free(asciidump);
-                HIP_DIE("hexdump msg too long(%d)", hexdump_written);
-            }
-            hexdump_count -= hexdump_written;
-            HIP_ASSERT(hexdump_count >= 0);
-            hexdump_index += hexdump_written;
-            HIP_ASSERT(hexdump_index + hexdump_count == hexdump_total_size);
-
-            /* Write the character in ascii to ascii dump line */
-            if (written > 32 && written < 127) {
-                memset(asciidump + line_index, written, 1);
-            } else {
-                memset(asciidump + line_index, nonascii, 1);
-            }
-            line_index++;
-            /* If line is full or input is all read, copy data to hexdump */
-            if (line_index >= 16 || (char_index + 1) == len) {
-                /* Add padding */
-                if ((char_index + 1) == len && pad_length > 0
-                    && ((hexdump_index + line_index + pad_length) < 
hexdump_total_size)) {
-                    char *padding = calloc(pad_length + 1, sizeof(char));
-                    memset(padding, ' ', pad_length);
-                    memset(padding + pad_length, '\0', 1);
-                    hexdump_written = snprintf((char *) (hexdump + 
hexdump_index),
-                                               hexdump_count, "%s", padding);
-                    if (hexdump_written < 0 || hexdump_written > 
hexdump_total_size - 1) {
-                        free(hexdump);
-                        free(asciidump);
-                        free(padding);
-                        HIP_DIE("hexdump msg too long(%d)", hexdump_written);
-                    }
-                    hexdump_index += hexdump_written;
-                    hexdump_count -= hexdump_written;
-                    free(padding);
-                }
-                memset(asciidump + line_index, '\n', 1);
-                memset(asciidump + line_index + 1, '\0', 1);
-                hexdump_written = snprintf((char *) (hexdump + hexdump_index),
-                                           hexdump_count, "%s", asciidump);
-                if (hexdump_written < 0 || hexdump_written > 
hexdump_total_size - 1) {
-                    free(hexdump);
-                    free(asciidump);
-                    HIP_DIE("hexdump msg too long(%d)", hexdump_written);
-                }
-                hexdump_index += hexdump_written;
-                hexdump_count -= hexdump_written;
-                line_index     = 0;
-                memset(asciidump, 0, bytes_per_line + 2);
-            }
-            char_index++;
+        const size_t buffer_size = hip_mem2pretty_hex_size(len);
+        char* buffer = malloc(buffer_size);
+        if (buffer != NULL) {
+            hip_mem2pretty_hex(str, len, buffer, buffer_size);
+            hip_print_str(DEBUG_LEVEL_DEBUG, file, line, function, "%s%s\n", 
prefix, buffer);
+            free(buffer);
+        } else {
+            HIP_DIE("memory allocation failed\n");
         }
-        hip_print_str(DEBUG_LEVEL_DEBUG, file, line, function, "%s%s\n", 
prefix, hexdump);
-    } else {
-        HIP_ERROR("hexdump length was 0\n");
     }
-
-    free(hexdump);
-    free(asciidump);
-
-    return 0;
 }
 
 /**

=== modified file 'lib/core/debug.h'
--- lib/core/debug.h    2010-09-07 11:40:26 +0000
+++ lib/core/debug.h    2010-11-09 16:37:54 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -339,13 +337,13 @@
                  const char *function,
                  const char *prefix,
                  const void *str,
-                 int len);
-int hip_hexdump_parsed(const char *file,
-                       int line,
-                       const char *function,
-                       const char *prefix,
-                       const void *str,
-                       int len);
+                 const size_t len);
+void hip_hexdump_parsed(const char *file,
+                        int line,
+                        const char *function,
+                        const char *prefix,
+                        const void *str,
+                        const size_t len);
 void hip_print_packet(const char *file,
                       int line,
                       const char *function,

=== modified file 'lib/core/filemanip.c'
--- lib/core/filemanip.c        2010-08-24 17:14:01 +0000
+++ lib/core/filemanip.c        2010-10-18 17:44:31 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * @brief file manipulation tools
  *
  * @author Miika Komu <miika@xxxxxx>
@@ -164,7 +165,7 @@
 }
 
 /**
- * make /etc/hip file permissions more secure
+ * Make HIPL_SYSCONFDIR file permissions more secure.
  *
  * @param filenamebase the file name based for keys
  */

=== modified file 'lib/core/filemanip.h'
--- lib/core/filemanip.h        2010-07-04 17:54:18 +0000
+++ lib/core/filemanip.h        2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'lib/core/hashchain.c'
--- lib/core/hashchain.c        2010-07-14 15:58:20 +0000
+++ lib/core/hashchain.c        2010-10-27 11:11:20 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,14 +21,16 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * API for a hash chain API
  *
  * @brief API for a hash chain API
  *
  * @author Tobias Heer <heer@xxxxxxxxxx>
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #include <stdlib.h>
@@ -200,19 +200,19 @@
 /* getter function for a specific element of the given hash chain
  *
  * @param       hash_chain hash chain from which the element should be returned
- * @param       index index to the hash chain element
+ * @param       idx index to the hash chain element
  * @return      element of the given hash chain
  */
 static unsigned char *hchain_element_by_index(const hash_chain_t *hash_chain,
-                                              const int index)
+                                              const int idx)
 {
     unsigned char *element = NULL;
     int err                = 0;
 
     HIP_ASSERT(hash_chain);
 
-    if (index >= 0 && index < hash_chain->hchain_length) {
-        element = &hash_chain->elements[index * hash_chain->hash_length];
+    if (idx >= 0 && idx < hash_chain->hchain_length) {
+        element = &hash_chain->elements[idx * hash_chain->hash_length];
     } else {
         HIP_ERROR("Element from uninited hash chain or out-of-bound element 
requested!");
 

=== modified file 'lib/core/hashchain.h'
--- lib/core/hashchain.h        2010-07-14 16:07:06 +0000
+++ lib/core/hashchain.h        2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,14 +21,16 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * API for a hash chain API
  *
  * @brief API for a hash chain API
  *
  * @author Tobias Heer <heer@xxxxxxxxxx>
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #ifndef HIP_LIB_CORE_HASHCHAIN_H

=== modified file 'lib/core/hashchain_store.c'
--- lib/core/hashchain_store.c  2010-07-14 15:58:20 +0000
+++ lib/core/hashchain_store.c  2010-10-18 17:44:31 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * Stores a number of pre-created hash structures and supports HHL-based
  * linking of hash structures in different hierarchy levels.
  *
@@ -31,7 +32,6 @@
  *
  * @author Tobias Heer <heer@xxxxxxxxxx>
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #include <string.h>

=== modified file 'lib/core/hashchain_store.h'
--- lib/core/hashchain_store.h  2010-07-04 17:54:18 +0000
+++ lib/core/hashchain_store.h  2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * Stores a number of pre-created hash structures and supports HHL-based
  * linking of hash structures in different hierarchy levels.
  *
@@ -31,7 +32,6 @@
  *
  * @author Tobias Heer <heer@xxxxxxxxxx>
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #ifndef HIP_LIB_CORE_HASHCHAIN_STORE_H

=== modified file 'lib/core/hashtable.c'
--- lib/core/hashtable.c        2010-07-16 14:42:09 +0000
+++ lib/core/hashtable.c        2010-10-19 02:38:50 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * Hashtable wrappers for OpenSSL lhash implementation. Originally
  * introduced to HIPL to hide transition of swithing between different
  * hashtable implementations. Now the wrappers are mainly used to hide
@@ -75,16 +76,14 @@
     return ptr1 != ptr2;
 }
 
-#ifdef HIPL_OPENSSL_100
-
 /**
  * Returns a generic linked list based on the hash table implementation
  *
  * @return an allocated hash table which is caller is responsible to free
  */
-LHASH_OF(HIP_HT) * hip_linked_list_init(void)
+HIP_HASHTABLE_TYPE *hip_linked_list_init(void)
 {
-  return (LHASH_OF(HIP_HT) *) hip_ht_init(hip_hash_generic, hip_match_generic);
+    return hip_ht_init(hip_hash_generic, hip_match_generic);
 }
 
 /**
@@ -95,25 +94,11 @@
  * @return The allocated hashtable that the caller must free with 
hip_ht_uninit().
  *         NULL on error.
  */
-LHASH_OF(HIP_HT) * hip_ht_init(LHASH_HASH_FN_TYPE hashfunc, LHASH_COMP_FN_TYPE 
cmpfunc)
-{
-    return (LHASH_OF(HIP_HT) *)lh_new(hashfunc, cmpfunc);
-}
-
-#else /* not HIPL_OPENSSL_100 */
-
-HIP_HASHTABLE *hip_linked_list_init(void)
-{
-    return (HIP_HASHTABLE *) hip_ht_init(hip_hash_generic, hip_match_generic);
-}
-
-HIP_HASHTABLE *hip_ht_init(LHASH_HASH_FN_TYPE hashfunc,
-                           LHASH_COMP_FN_TYPE cmpfunc)
-{
-    return (HIP_HASHTABLE *) lh_new(hashfunc, cmpfunc);
-}
-
-#endif /* HIPL_OPENSSL_100 */
+HIP_HASHTABLE_TYPE *hip_ht_init(LHASH_HASH_FN_TYPE hashfunc,
+                                LHASH_COMP_FN_TYPE cmpfunc)
+{
+    return (HIP_HASHTABLE_TYPE *) lh_new(hashfunc, cmpfunc);
+}
 
 /**
  * Unitilialize a hashtable that was allocated using hip_ht_init()

=== modified file 'lib/core/hashtable.h'
--- lib/core/hashtable.h        2010-07-14 16:07:06 +0000
+++ lib/core/hashtable.h        2010-10-19 03:09:20 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -45,20 +43,18 @@
 #define HIP_LOCK_HT(hash)
 #define HIP_UNLOCK_HT(hash)
 
-void hip_ht_uninit(void *head);
-void *hip_ht_find(void *head, const void *data);
-void *hip_ht_delete(void *head, void *data);
-int hip_ht_add(void *head, void *data);
+#define STATIC_IMPLEMENT_LHASH_COMP_FN      static IMPLEMENT_LHASH_COMP_FN
+#define STATIC_IMPLEMENT_LHASH_DOALL_FN     static IMPLEMENT_LHASH_DOALL_FN
+#define STATIC_IMPLEMENT_LHASH_DOALL_ARG_FN static IMPLEMENT_LHASH_DOALL_ARG_FN
+#define STATIC_IMPLEMENT_LHASH_HASH_FN      static IMPLEMENT_LHASH_HASH_FN
+
 
 #ifdef HIPL_OPENSSL_100
 
 #define LHASH100_CAST _LHASH
 
-typedef DECLARE_LHASH_OF (HIP_HT) hip_ht_common;
-typedef hip_ht_common HIP_HASHTABLE;
-
-LHASH_OF(HIP_HT) * hip_linked_list_init(void);
-LHASH_OF(HIP_HT) * hip_ht_init(LHASH_HASH_FN_TYPE hashfunc, LHASH_COMP_FN_TYPE 
cmpfunc);
+typedef DECLARE_LHASH_OF(HIP_HT) HIP_HASHTABLE;
+typedef LHASH_OF(HIP_HT)         HIP_HASHTABLE_TYPE;
 
 #else
 
@@ -90,15 +86,21 @@
         o_type *a = arg1; \
         a_type *b = arg2; \
         name ## _doall_arg(a, b); }
-typedef DECLARE_LHASH_OF (HIP_HT) hip_ht_common;
-typedef LHASH HIP_HASHTABLE;
-
-HIP_HASHTABLE *hip_linked_list_init(void);
-HIP_HASHTABLE *hip_ht_init(LHASH_HASH_FN_TYPE hashfunc,
-                           LHASH_COMP_FN_TYPE cmpfunc);
+
+typedef LHASH         HIP_HASHTABLE;
+typedef HIP_HASHTABLE HIP_HASHTABLE_TYPE;
+
 #endif
 
+HIP_HASHTABLE_TYPE *hip_linked_list_init(void);
+HIP_HASHTABLE_TYPE *hip_ht_init(LHASH_HASH_FN_TYPE hashfunc,
+                                LHASH_COMP_FN_TYPE cmpfunc);
+void hip_ht_uninit(void *head);
+void *hip_ht_find(void *head, const void *data);
+void *hip_ht_delete(void *head, void *data);
+int hip_ht_add(void *head, void *data);
 void hip_ht_doall(void *head, LHASH_DOALL_FN_TYPE func);
-void hip_ht_doall_arg(void *head, LHASH_DOALL_ARG_FN_TYPE func, void *arg);
+void hip_ht_doall_arg(void *head, LHASH_DOALL_ARG_FN_TYPE func,
+                      void *arg);
 
 #endif /* HIP_LIB_CORE_HASHTABLE_H */

=== modified file 'lib/core/hashtree.c'
--- lib/core/hashtree.c 2010-07-14 15:58:20 +0000
+++ lib/core/hashtree.c 2010-10-18 17:44:31 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,14 +21,16 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * API for Hash trees
  *
  * @brief API for Hash trees
  *
  * @author Tobias Heer <heer@xxxxxxxxxx>
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #include <math.h>

=== modified file 'lib/core/hashtree.h'
--- lib/core/hashtree.h 2010-07-14 16:07:06 +0000
+++ lib/core/hashtree.h 2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,14 +21,16 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * API for Hash trees
  *
  * @brief API for Hash trees
  *
  * @author Tobias Heer <heer@xxxxxxxxxx>
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #ifndef HIP_LIB_CORE_HASHTREE_H

=== modified file 'lib/core/hip_udp.c'
--- lib/core/hip_udp.c  2010-07-14 15:58:20 +0000
+++ lib/core/hip_udp.c  2010-10-18 17:44:31 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * @brief UDP-related functions
  *
  * @author Miika Komu <miika@xxxxxx>

=== modified file 'lib/core/hip_udp.h'
--- lib/core/hip_udp.h  2010-07-04 17:54:18 +0000
+++ lib/core/hip_udp.h  2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'lib/core/hit.c'
--- lib/core/hit.c      2010-08-29 16:24:14 +0000
+++ lib/core/hit.c      2010-10-19 23:21:39 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,89 +21,65 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * @brief HIT-related utility functions
  *
  * @author Miika Komu <miika@xxxxxx>
  */
 
-#include <stdint.h>
-#include <string.h>
+#include <string.h>     // strcpy()
 
-#include "config.h"
-#include "builder.h"
-#include "debug.h"
-#include "prefix.h"
-#include "protodefs.h"
-#include "straddr.h"
+#include "debug.h"      // HIP_ASSERT()
+#include "prefix.h"     // ipv6_addr_cmp()
+#include "straddr.h"    // hip_in6_ntop()
 #include "hit.h"
 
 /**
- * convert a binary HIT into a string
+ * Convert a binary HIT to a hexadecimal string representation of the form
+ * 0011:2233:4455:6677:8899:AABB:CCDD:EEFF terminated by a null character.
  *
- * @param hit a binary HIT
- * @param prefix an optional HIT prefix as a string
- * @param hit_str the HIT as a string with the given prefix
- * @return zero on success and negative on error
+ * @param hit a pointer to a binary HIT.
+ * @param suffix an optional null-terminated string suffix to be appended to
+ *  the HIT. If suffix is NULL or the empty string, no suffix is appended. If
+ *  suffix is not null-terminated, the result is undefined.
+ * @param hit_str a pointer to a buffer to write the HIT and the suffix to. The
+ *  result of passing a buffer that is too short to hold the string
+ *  representation plus the suffix is undefined.
+ * @return 0 if the HIT was successfully converted. Returns a negative value if
+ *  hit is NULL or hit_str is NULL.
  */
-int hip_convert_hit_to_str(const hip_hit_t *hit,
-                           const char *prefix,
-                           char *hit_str)
+int hip_convert_hit_to_str(const hip_hit_t *const hit,
+                           const char *const suffix,
+                           char *const hit_str)
 {
-    int err = 0;
-
-    HIP_ASSERT(hit);
-
-    memset(hit_str, 0, INET6_ADDRSTRLEN);
-    err = !hip_in6_ntop(hit, hit_str);
-
-    if (prefix) {
-        memcpy(hit_str + strlen(hit_str), prefix, strlen(prefix));
+    if (hit && hit_str) {
+        if (hip_in6_ntop(hit, hit_str)) {
+            if (suffix && *suffix != '\0') {
+                strcpy(hit_str + strlen(hit_str), suffix);
+            }
+            return 0;
+        }
     }
 
-    return err;
-}
-/**
- * compare two HITs to check which HIT is "bigger"
- *
- * @param hit1 the first HIT to be compared
- * @param hit2 the second HIT to be compared
- *
- * @return 1 if hit1 was bigger than hit2, or else 0
- */
-int hip_hit_is_bigger(const struct in6_addr *hit1,
-                      const struct in6_addr *hit2)
-{
-    return ipv6_addr_cmp(hit1, hit2) > 0;
-}
-
-/**
- * compare two HITs to check which if they are equal
- *
- * @param hit1 the first HIT to be compared
- * @param hit2 the second HIT to be compared
- *
- * @return 1 if the HITs were equal and zero otherwise
- */
-int hip_hit_are_equal(const struct in6_addr *hit1,
-                      const struct in6_addr *hit2)
-{
-    return ipv6_addr_cmp(hit1, hit2) == 0;
-}
-
-/**
- * calculate a hash from a HIT
- *
- * @param ptr pointer to a HIT
- *
- * Returns value in range: 0 <= x < range
- */
-unsigned long hip_hash_hit(const void *ptr)
-{
-    uint8_t hash[HIP_AH_SHA_LEN];
-
-    hip_build_digest(HIP_DIGEST_SHA1, (const uint8_t *)ptr + sizeof(uint16_t),
-                     7 * sizeof(uint16_t), hash);
-
-    return *((unsigned long *) hash);
+    return -1;
+}
+
+/**
+ * Determine whether a HIT is numerically greater than another.
+ *
+ * @param hit_gt    a pointer to a HIT. When passing a NULL pointer, the result
+ *  of this function is undefined.
+ * @param hit_le    a pointer to a HIT. When passing a NULL pointer, the result
+ *  of this function is undefined.
+ * @return 1 if hit_gt is greater than hit_le, otherwise 0.
+ */
+int hip_hit_is_bigger(const struct in6_addr *const hit_gt,
+                      const struct in6_addr *const hit_le)
+{
+    HIP_ASSERT(hit_gt);
+    HIP_ASSERT(hit_le);
+    return ipv6_addr_cmp(hit_gt, hit_le) > 0;
 }

=== modified file 'lib/core/hit.h'
--- lib/core/hit.h      2010-07-14 16:01:50 +0000
+++ lib/core/hit.h      2010-10-19 12:08:54 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -32,11 +30,8 @@
 
 #include "protodefs.h"
 
-int hip_convert_hit_to_str(const hip_hit_t *hit, const char *prefix, char 
*str);
-int hip_hit_is_bigger(const struct in6_addr *hit1,
-                      const struct in6_addr *hit2);
-int hip_hit_are_equal(const struct in6_addr *hit1,
-                      const struct in6_addr *hit2);
-unsigned long hip_hash_hit(const void *hit);
+int hip_convert_hit_to_str(const hip_hit_t *const hit, const char *const 
suffix, char *const str);
+int hip_hit_is_bigger(const struct in6_addr *const hit_gt,
+                      const struct in6_addr *const hit_le);
 
 #endif /* HIP_LIB_CORE_HIT_H */

=== modified file 'lib/core/hostid.c'
--- lib/core/hostid.c   2010-08-20 14:34:13 +0000
+++ lib/core/hostid.c   2010-10-18 17:44:31 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * @brief Host identifier manipulation functions
  *
  * @author Miika Komu <miika@xxxxxx>
@@ -192,7 +193,7 @@
 
     contents_len = ntohs(host_id->hi_length);
 
-    /*! \todo add an extra check for the T val */
+    /** @todo add an extra check for the T val */
 
     HIP_IFEL(contents_len <= 20, -EMSGSIZE, "Host id too short\n");
 
@@ -458,7 +459,7 @@
  *               ACTION_NEW will override the existing identities on disk!
  * @param anon set to one when you want to process only anonymous (short-term)
  *             identities or zero otherwise
- * @param use_default One when dealing with default identities in /etc/hip.
+ * @param use_default One when dealing with default identities in 
HIPL_SYSCONFDIR.
  *                    Zero when user supplies own identities denoted by
  *                    @c hi_file argument.
  * @param hi_fmt "dsa" or "rsa" currently supported
@@ -544,7 +545,7 @@
         if (hi_fmt == NULL || !strcmp(hi_fmt, "dsa")) {
             dsa_filenamebase_len =
                 strlen(HIPL_SYSCONFDIR) +
-                strlen(DEFAULT_HOST_DSA_KEY_FILE_BASE) + 1;
+                strlen(DEFAULT_HOST_DSA_KEY_FILE_BASE);
 
             if (anon || hi_fmt == NULL) {
                 dsa_filenamebase     = malloc(HOST_ID_FILENAME_MAX_LEN);
@@ -552,8 +553,7 @@
                          "Could not allocate DSA filename.\n");
 
                 ret = snprintf(dsa_filenamebase,
-                               dsa_filenamebase_len +
-                               strlen(DEFAULT_ANON_HI_FILE_NAME_SUFFIX),
+                               HOST_ID_FILENAME_MAX_LEN,
                                "%s%s%s",
                                HIPL_SYSCONFDIR,
                                DEFAULT_HOST_DSA_KEY_FILE_BASE,
@@ -586,7 +586,7 @@
         if (hi_fmt == NULL || !strcmp(hi_fmt, "rsa")) {
             rsa_filenamebase_len =
                 strlen(HIPL_SYSCONFDIR) +
-                strlen(DEFAULT_HOST_RSA_KEY_FILE_BASE) + 1;
+                strlen(DEFAULT_HOST_RSA_KEY_FILE_BASE);
 
             if (anon || hi_fmt == NULL) {
                 rsa_filenamebase =
@@ -594,12 +594,12 @@
                 HIP_IFEL(!rsa_filenamebase, -ENOMEM,
                          "Could not allocate RSA filename.\n");
 
-                ret = snprintf(
-                    rsa_filenamebase,
-                    HOST_ID_FILENAME_MAX_LEN, "%s%s%s",
-                    HIPL_SYSCONFDIR,
-                    DEFAULT_HOST_RSA_KEY_FILE_BASE,
-                    DEFAULT_ANON_HI_FILE_NAME_SUFFIX);
+                ret = snprintf(rsa_filenamebase,
+                               HOST_ID_FILENAME_MAX_LEN,
+                               "%s%s%s",
+                               HIPL_SYSCONFDIR,
+                               DEFAULT_HOST_RSA_KEY_FILE_BASE,
+                               DEFAULT_ANON_HI_FILE_NAME_SUFFIX);
 
                 HIP_IFE(ret <= 0, -EINVAL);
 
@@ -614,13 +614,12 @@
                          "Could not allocate RSA (pub) " \
                          "filename.\n");
 
-                ret = snprintf(
-                    rsa_filenamebase_pub,
-                    rsa_filenamebase_len +
-                    strlen(DEFAULT_PUB_HI_FILE_NAME_SUFFIX),
-                    "%s%s%s", HIPL_SYSCONFDIR,
-                    DEFAULT_HOST_RSA_KEY_FILE_BASE,
-                    DEFAULT_PUB_HI_FILE_NAME_SUFFIX);
+                ret = snprintf(rsa_filenamebase_pub,
+                               HOST_ID_FILENAME_MAX_LEN,
+                               "%s%s%s",
+                               HIPL_SYSCONFDIR,
+                               DEFAULT_HOST_RSA_KEY_FILE_BASE,
+                               DEFAULT_PUB_HI_FILE_NAME_SUFFIX);
 
                 HIP_IFE(ret <= 0, -EINVAL);
 

=== modified file 'lib/core/hostid.h'
--- lib/core/hostid.h   2010-07-04 17:54:18 +0000
+++ lib/core/hostid.h   2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'lib/core/hostsfiles.c'
--- lib/core/hostsfiles.c       2010-08-19 09:32:20 +0000
+++ lib/core/hostsfiles.c       2010-10-18 17:44:31 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,13 +21,16 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This file contains iterator functions to access and parse
- * /etc/hosts and /etc/hip/hosts files. Also, this file contains a
- * number of predefined functions that support mapping between
+ * /etc/hosts and HIPL_SYSCONFDIR/hosts files. Also, this file contains
+ * a number of predefined functions that support mapping between
  * hostnames, HITs, LSIs and routable IP addresses.
  *
- * @brief parser for /etc/hosts and /etc/hip/hosts
+ * @brief parser for /etc/hosts and HIPL_SYSCONFDIR/hosts
  *
  * @author Miika Komu <miika@xxxxxx>
  *
@@ -56,8 +57,8 @@
 #define HOSTS_FILE "/etc/hosts"
 
 /**
- * "For-each" loop to iterate through /etc/hosts or /etc/hip/hosts file, line
- * by line.
+ * "For-each" loop to iterate through /etc/hosts or HIPL_SYSCONFDIR/hosts
+ * file, line by line.
  *
  * @param hosts_file the path and name to the hosts file
  * @param func the iterator function pointer
@@ -66,11 +67,11 @@
  * @return zero on success or non-zero on failure
  */
 static int hip_for_each_hosts_file_line(const char *hosts_file,
-                                                   int(*func)(const struct 
hosts_file_line *line,
-                                                              const void *arg,
-                                                              void *result),
+                                        int(*func)(const struct 
hosts_file_line *line,
                                                    const void *arg,
-                                                   void *result)
+                                                   void *result),
+                                        const void *arg,
+                                        void *result)
 {
     FILE *hip_hosts = NULL;
     List mylist;
@@ -89,8 +90,8 @@
 
     HIP_IFEL(!hip_hosts, -1, "Failed to open hosts file\n");
 
-    /* For each line in the given hosts file, convert the line into binary 
format and
-     * call the given the handler  */
+    /* For each line in the given hosts file, convert the line into binary
+     * format and call the given the handler  */
 
     err = 1;
     while (fgets(line, sizeof(line) - 1, hip_hosts) != NULL) {
@@ -252,7 +253,7 @@
 }
 
 /**
- * find the hostname matching the given LSI from /etc/hip/hosts and
+ * find the hostname matching the given LSI from HIPL_SYSCONFDIR/hosts and
  * /etc/hosts (in this particular order)
  *
  * @param lsi the LSI to match
@@ -377,7 +378,7 @@
 }
 
 /**
- * find the HIT matching to the given LSI from /etc/hip/hosts and
+ * find the HIT matching to the given LSI from HIPL_SYSCONFDIR/hosts and
  * /etc/hosts (in this particular order)
  *
  * @param lsi the LSI to match
@@ -426,7 +427,7 @@
 }
 
 /**
- * find the LSI matching to the given HIT from /etc/hip/hosts and
+ * find the LSI matching to the given HIT from HIPL_SYSCONFDIR/hosts and
  * /etc/hosts (in this particular order)
  *
  * @param hit the HIT to match
@@ -469,10 +470,12 @@
 }
 
 /**
- * This function maps a HIT or a LSI (nodename) to an IP address using the two 
hosts files.
- * The function implements this in two steps. First, it maps the HIT or LSI to 
an hostname
- * from /etc/hip/hosts or /etc/hosts. Second, it maps the hostname to a IP 
address from
- * /etc/hosts. The IP address is returned in the res argument.
+ * This function maps a HIT or a LSI (nodename) to an IP address using
+ * the two hosts files.
+ * The function implements this in two steps. First, it maps the HIT or
+ * LSI to an hostname from HIPL_SYSCONFDIR/hosts or /etc/hosts. Second, it
+ * maps the hostname to an IP address from /etc/hosts. The IP address
+ * is returned in the res argument.
  *
  * @param hit a HIT to be mapped
  * @param lsi an LSI to be mapped

=== modified file 'lib/core/hostsfiles.h'
--- lib/core/hostsfiles.h       2010-08-19 09:32:20 +0000
+++ lib/core/hostsfiles.h       2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'lib/core/icomm.h'
--- lib/core/icomm.h    2010-08-25 09:06:43 +0000
+++ lib/core/icomm.h    2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -212,6 +210,5 @@
     char port_and_protocol[FIREWALL_PORT_CACHE_KEY_LENGTH];     //key
     int  traffic_type;                                          //value
 };
-typedef struct firewall_port_cache_hl firewall_port_cache_hl_t;
 
 #endif /* HIP_LIB_CORE_ICOMM_H */

=== modified file 'lib/core/ife.h'
--- lib/core/ife.h      2010-07-14 16:01:50 +0000
+++ lib/core/ife.h      2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'lib/core/keylen.c'
--- lib/core/keylen.c   2010-07-04 17:54:18 +0000
+++ lib/core/keylen.c   2010-10-18 17:44:31 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * @brief Various key length calculation functions
  *
  * @author Miika Komu <miika@xxxxxx>

=== modified file 'lib/core/keylen.h'
--- lib/core/keylen.h   2010-07-04 17:54:18 +0000
+++ lib/core/keylen.h   2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'lib/core/linkedlist.c'
--- lib/core/linkedlist.c       2010-07-04 17:54:18 +0000
+++ lib/core/linkedlist.c       2010-10-18 17:44:31 +0000
@@ -1,8 +1,5 @@
-/** @file
- * This file defines a linked list for storing pointers.
- *
- * @author  Lauri Silvennoinen
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -24,8 +21,16 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file
+ * This file defines a linked list for storing pointers.
+ *
+ * @author  Lauri Silvennoinen
  * @see     linkedlist.h for usage instructions.
  */
+
 #include <stdlib.h> /* For malloc(). */
 
 #include "debug.h"

=== modified file 'lib/core/linkedlist.h'
--- lib/core/linkedlist.h       2010-07-04 17:54:18 +0000
+++ lib/core/linkedlist.h       2010-10-15 15:29:14 +0000
@@ -1,22 +1,5 @@
-/** @file
- * A header file for linkedlist.c
- *
- * We are using following notation in this file:
- * <pre>
- * +------------+   head   +---------+   next   +---------+
- * | linkedlist |--------->|   node  |--------->|   node  |--  ...  --> NULL
- * +------------+          +--------+-          +---------+
- *                              |                    |
- *                              | ptr                | ptr
- *                              v                    v
- *                         +---------+          +---------+
- *                         | element |          | element |
- *                         +---------+          +---------+
- * </pre>where element contains the payload data.
- * @author  Lauri Silvennoinen
- * @version 1.0
- * @date    21.04.2008
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -40,6 +23,26 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
+/**
+ * @file
+ *
+ * We are using following notation in this file:
+ * <pre>
+ * +------------+   head   +---------+   next   +---------+
+ * | linkedlist |--------->|   node  |--------->|   node  |--  ...  --> NULL
+ * +------------+          +--------+-          +---------+
+ *                              |                    |
+ *                              | ptr                | ptr
+ *                              v                    v
+ *                         +---------+          +---------+
+ *                         | element |          | element |
+ *                         +---------+          +---------+
+ * </pre>where element contains the payload data.
+ * @author  Lauri Silvennoinen
+ * @version 1.0
+ * @date    21.04.2008
+ */
+
 #ifndef HIP_LIB_CORE_LINKEDLIST_H
 #define HIP_LIB_CORE_LINKEDLIST_H
 

=== modified file 'lib/core/list.h'
--- lib/core/list.h     2010-07-14 14:09:30 +0000
+++ lib/core/list.h     2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'lib/core/message.c'
--- lib/core/message.c  2010-07-14 15:58:20 +0000
+++ lib/core/message.c  2010-10-18 17:44:31 +0000
@@ -1,6 +1,5 @@
-/** @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -22,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This file contains functions to read and writing of HIP-related
  * messages. HIP message format is overloaded (see builder.c) so that
  * interprocess and network communications share roughly the same message
@@ -202,8 +204,7 @@
     daemon_addr.sin6_addr   = in6addr_loopback;
 
     HIP_IFEL(connect(hip_user_sock, (struct sockaddr *) &daemon_addr,
-                     sizeof(daemon_addr)), -1,
-             "connection to daemon failed\n");
+             sizeof(daemon_addr)), -1, "connection to daemon failed\n");
 
 out_err:
 
@@ -558,9 +559,6 @@
 
     hip_msg_init(ctx->input_msg);
 
-    HIP_ASSERT(ctx->src_addr);
-    HIP_ASSERT(ctx->dst_addr);
-
     HIP_DEBUG("hip_read_control_msg_all() invoked.\n");
 
 //    memset(msg_info, 0, sizeof(hip_portpair_t));
@@ -613,31 +611,31 @@
     /* UDP port numbers */
     if (is_ipv4 && encap_hdr_size == HIP_UDP_ZERO_BYTES_LEN) {
         HIP_DEBUG("source port = %d\n", ntohs(addr_from4->sin_port));
-        ctx->msg_ports->src_port = ntohs(addr_from4->sin_port);
+        ctx->msg_ports.src_port = ntohs(addr_from4->sin_port);
         /* Destination port is known from the bound socket. */
-        ctx->msg_ports->dst_port = hip_get_local_nat_udp_port();
+        ctx->msg_ports.dst_port = hip_get_local_nat_udp_port();
     } else {
-        ctx->msg_ports->src_port = 0;
-        ctx->msg_ports->dst_port = 0;
+        ctx->msg_ports.src_port = 0;
+        ctx->msg_ports.dst_port = 0;
    }
 
     /* IPv4 addresses */
     if (is_ipv4) {
         struct sockaddr_in *addr_to4 = (struct sockaddr_in *) &addr_to;
-        IPV4_TO_IPV6_MAP(&addr_from4->sin_addr, ctx->src_addr);
-        IPV4_TO_IPV6_MAP(&pktinfo.pktinfo_in4->ipi_addr, ctx->dst_addr);
+        IPV4_TO_IPV6_MAP(&addr_from4->sin_addr, &ctx->src_addr);
+        IPV4_TO_IPV6_MAP(&pktinfo.pktinfo_in4->ipi_addr, &ctx->dst_addr);
         addr_to4->sin_family = AF_INET;
         addr_to4->sin_addr   = pktinfo.pktinfo_in4->ipi_addr;
-        addr_to4->sin_port   = ctx->msg_ports->dst_port;
+        addr_to4->sin_port   = ctx->msg_ports.dst_port;
     } else {   /* IPv6 addresses */
         struct sockaddr_in6 *addr_to6 =
             (struct sockaddr_in6 *) &addr_to;
-        memcpy(ctx->src_addr, &addr_from6->sin6_addr,
+        memcpy(&ctx->src_addr, &addr_from6->sin6_addr,
                sizeof(struct in6_addr));
-        memcpy(ctx->dst_addr, &pktinfo.pktinfo_in6->ipi6_addr,
+        memcpy(&ctx->dst_addr, &pktinfo.pktinfo_in6->ipi6_addr,
                sizeof(struct in6_addr));
         addr_to6->sin6_family = AF_INET6;
-        ipv6_addr_copy(&addr_to6->sin6_addr, ctx->dst_addr);
+        ipv6_addr_copy(&addr_to6->sin6_addr, &ctx->dst_addr);
     }
 
     if (is_ipv4 && (encap_hdr_size == IPV4_HDR_SIZE)) {    /* raw IPv4, !UDP */
@@ -661,12 +659,8 @@
 
 
 
-    if (ctx->src_addr) {
-        HIP_DEBUG_IN6ADDR("src", ctx->src_addr);
-    }
-    if (ctx->dst_addr) {
-        HIP_DEBUG_IN6ADDR("dst", ctx->dst_addr);
-    }
+    HIP_DEBUG_IN6ADDR("src", &ctx->src_addr);
+    HIP_DEBUG_IN6ADDR("dst", &ctx->dst_addr);
 
 out_err:
     return err;

=== modified file 'lib/core/message.h'
--- lib/core/message.h  2010-07-04 17:54:18 +0000
+++ lib/core/message.h  2010-10-15 15:29:14 +0000
@@ -1,10 +1,5 @@
-/** @file
- * A header file for message.c.
- *
- * @author  Miika Komu <miika_iki.fi>
- * @author  Bing Zhou <bingzhou_cc.hut.fi>
- * @version 1.0
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -28,6 +23,13 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
+/**
+ * @file
+ * @author  Miika Komu <miika_iki.fi>
+ * @author  Bing Zhou <bingzhou_cc.hut.fi>
+ * @version 1.0
+ */
+
 #ifndef HIP_LIB_CORE_MESSAGE_H
 #define HIP_LIB_CORE_MESSAGE_H
 

=== modified file 'lib/core/performance.c'
--- lib/core/performance.c      2010-07-14 15:58:20 +0000
+++ lib/core/performance.c      2010-10-18 17:44:31 +0000
@@ -1,14 +1,5 @@
-/*!
- * \file dh_performance.c
- *
- * \brief Primitive performance measurement library.
- * \author Tobias Heer
- *
- * This file provides a set of functions to measure execution time.
- * The measurement unit is second.
- *
- * \note Distributed under
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -30,7 +21,17 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
+ *
+ * @brief Primitive performance measurement library.
+ * @author Tobias Heer
+ * @author Dongsu Park
+ *
+ * This file provides a set of functions to measure execution time.
+ * The measurement unit is second.
  */
 
 #include <stdio.h>
@@ -42,19 +43,17 @@
 #include "ife.h"
 #include "performance.h"
 
-/*!
- * \brief Create a set of performance slots. Each performance measurement type
+/**
+ * @brief Create a set of performance slots. Each performance measurement type
  * needs a slot.
  *
  * Create a set of performance slots. Each performance measurement type needs
  * a slot. This is the first step when starting measurements.
  *
- * \author      Tobias Heer
- *
- * \param num Number of distinct sets to create.
- * \return A pointer to the performance set.
- *
- * \note The performance set memory must be freed after finishing the tests.
+ * @param num Number of distinct sets to create.
+ * @return A pointer to the performance set.
+ *
+ * @note The performance set memory must be freed after finishing the tests.
  */
 perf_set_t *hip_perf_create(int num)
 {
@@ -90,17 +89,16 @@
     return perf_set;
 }
 
-/*!
- * \brief Set the filename for an performance slot..
+/**
+ * @brief Set the filename for an performance slot.
  *
  * Assigns a filename to each performance measurement slot.
- * \author      Tobias Heer
  *
- * \param set The respective performance measurement created by 
hip_perf_create.
- * \see hip_perf_create
- * \param slot The slot number beginning with 0.
- * \param name The filename.
- * \return Returns error code. 0 = Success, 1 = Error.
+ * @param set The respective performance measurement created by 
hip_perf_create.
+ * @see hip_perf_create
+ * @param slot The slot number beginning with 0.
+ * @param name The filename.
+ * @return Returns error code. 0 = Success, 1 = Error.
  */
 int hip_perf_set_name(perf_set_t *set,  int slot, const char *name)
 {
@@ -117,16 +115,15 @@
     return err;
 }
 
-/*!
- * \brief Open the files for result output.
+/**
+ * @brief Open the files for result output.
  *
  * Open the files for a specific perf set.
- * \author      Tobias Heer
  *
- * \see hip_perf_create
- * \note Filenames must have been set by hip_perf_set_name before calling this 
function.
- * \param set The respective performance measurement created by 
hip_perf_create.
- * \return Returns error code. 0 = Success, 1 = Error.
+ * @see hip_perf_create
+ * @note Filenames must have been set by hip_perf_set_name before calling this 
function.
+ * @param set The respective performance measurement created by 
hip_perf_create.
+ * @return Returns error code. 0 = Success, 1 = Error.
  */
 int hip_perf_open(perf_set_t *set)
 {
@@ -149,17 +146,16 @@
     return err;
 }
 
-/*!
- * \brief Start benchmarking for a perf set slot.
+/**
+ * @brief Start benchmarking for a perf set slot.
  *
  * Start taking the time for a perf set slot. Slots can overlap but should not
  * write to disk while another slot is active.
- * \author      Tobias Heer
  *
- * \see hip_perf_create
- * \param set The respective performance measurement created by 
hip_perf_create.
- * \param slot The slot number beginning with 0.
- * \return void
+ * @see hip_perf_create
+ * @param set The respective performance measurement created by 
hip_perf_create.
+ * @param slot The slot number beginning with 0.
+ * @return void
  */
 void hip_perf_start_benchmark(perf_set_t *set, int slot)
 {
@@ -169,22 +165,21 @@
     }
 }
 
-/*!
- * \brief Stop benchmarking for a perf set slot and memorize the result.
+/**
+ * @brief Stop benchmarking for a perf set slot and memorize the result.
  *
  * Stop taking the time for a perf set slot. Slots can overlap but should not
  * write to disk while another slot is active.
- * \author      Tobias Heer
  *
- * \note This function only writes results to the memory. For disk writes you
+ * @note This function only writes results to the memory. For disk writes you
  * need to run hip_perf_write_benchmark.
  *
- * \see hip_perf_write_benchmark
- * \see hip_perf_create
+ * @see hip_perf_write_benchmark
+ * @see hip_perf_create
  *
- * \param set The respective performance measurement created by 
hip_perf_create.
- * \param slot The slot number beginning with 0.
- * \return void
+ * @param set The respective performance measurement created by 
hip_perf_create.
+ * @param slot The slot number beginning with 0.
+ * @return void
  */
 void hip_perf_stop_benchmark(perf_set_t *set, int slot)
 {
@@ -198,20 +193,19 @@
     }
 }
 
-/*!
- * \brief Write the benchmark results to the files.
+/**
+ * @brief Write the benchmark results to the files.
  *
  * Save the benchmark results to the respective files.
- * \author      Tobias Heer
- *
- * \note Do not use this functions while other benchmarks are in progress. It 
may disturb the measurements.
- *
- * \see hip_perf_write_benchmark
- * \see hip_perf_create
- *
- * \param set The respective performance measurement created by 
hip_perf_create.
- * \param slot The slot number beginning with 0.
- * \return Returns error code. 0 = Success, 1 = Error.
+ *
+ * @note Do not use this functions while other benchmarks are in progress. It 
may disturb the measurements.
+ *
+ * @see hip_perf_write_benchmark
+ * @see hip_perf_create
+ *
+ * @param set The respective performance measurement created by 
hip_perf_create.
+ * @param slot The slot number beginning with 0.
+ * @return Returns error code. 0 = Success, 1 = Error.
  */
 int hip_perf_write_benchmark(perf_set_t *set, int slot)
 {
@@ -235,15 +229,14 @@
     return err;
 }
 
-/*!
- * \brief Deallocate memory of a performance set
+/**
+ * @brief Deallocate memory of a performance set
  *
  * Deallocate memory of the given performance set, including each member of
  * the perf_set_t data structure.
- * \author      Dongsu Park
  *
- * \param set The respective performance measurement created by 
hip_perf_create.
- * \return Nothing.
+ * @param set The respective performance measurement created by 
hip_perf_create.
+ * @return Nothing.
  */
 void hip_perf_destroy(perf_set_t *set)
 {

=== modified file 'lib/core/performance.h'
--- lib/core/performance.h      2010-07-04 17:54:18 +0000
+++ lib/core/performance.h      2010-10-18 17:31:53 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -28,35 +26,34 @@
 #ifndef HIP_LIB_CORE_PERFORMANCE_H
 #define HIP_LIB_CORE_PERFORMANCE_H
 
-/*
+/**
  * Primitive performance measurement
  *
- * Authors:
- * - Tobias Heer <heer@xxxxxxxxxx>
+ * @author Tobias Heer <heer@xxxxxxxxxx>
  */
 
 #include <stdio.h>
 
-/*! This performace set holds all measurements */
+/** This performace set holds all measurements */
 struct perf_set {
-    /*! \brief A pointer to names of output files */
-    FILE **         files;
-    /*! \brief A list of names of the perf sets. */
-    char **         names;
-    /*! \brief A list timeval time structs. */
+    /** @brief A pointer to names of output files */
+    FILE          **files;
+    /** @brief A list of names of the perf sets. */
+    char          **names;
+    /** @brief A list timeval time structs. */
     struct timeval *times;
-    /*! \brief A list of measured results. */
-    double *        result;
-    /*! \brief The number of perf sets. */
+    /** @brief A list of measured results. */
+    double         *result;
+    /** @brief The number of perf sets. */
     int             num_files;
-    /*! \brief A linecount.. */
-    int *           linecount;
-    /*! \brief Are the necessary files opened? 1=TRUE, 0=FALSE. */
+    /** @brief A linecount */
+    int            *linecount;
+    /** @brief Are the necessary files opened? 1=TRUE, 0=FALSE. */
     int             files_open;
-    /*! \brief Are measurements running? This is an integer field of the 
length num_files. */
-    int *           running;
-    /*! \brief Are the measurements writable (completed)? This is an integer 
field of the length num_files. */
-    int *           writable;
+    /** @brief Are measurements running? This is an integer field of the 
length num_files. */
+    int            *running;
+    /** @brief Are the measurements writable (completed)? This is an integer 
field of the length num_files. */
+    int            *writable;
 };
 
 typedef struct perf_set perf_set_t;
@@ -69,30 +66,31 @@
 int hip_perf_write_benchmark(perf_set_t *perf_set, int slot);
 void hip_perf_destroy(perf_set_t *perf_set);
 
-enum perf_sensor {PERF_I1,
-                  PERF_R1,
-                  PERF_I2,
-                  PERF_R2,
-                  PERF_UPDATE,
-                  PERF_VERIFY,
-                  PERF_BASE,
-                  PERF_CLOSE_SEND,
-                  PERF_HANDLE_CLOSE,
-                  PERF_HANDLE_CLOSE_ACK,
-                  PERF_CLOSE_COMPLETE,
-                  PERF_DSA_VERIFY_IMPL,
-                  PERF_RSA_VERIFY_IMPL,
-                  /* The firewall only uses the sensors given above, hence it
-                   * has a separate PERF_MAX. */
-                  PERF_MAX_FIREWALL,
-                  PERF_DH_CREATE,
-                  PERF_SIGN,
-                  PERF_DSA_SIGN_IMPL,
-                  PERF_I1_SEND,
-                  PERF_RSA_SIGN_IMPL,
-                  PERF_STARTUP,
-                  /* Number of sensors for the HIP daemon. */
-                  PERF_MAX
+enum perf_sensor {
+    PERF_I1,
+    PERF_R1,
+    PERF_I2,
+    PERF_R2,
+    PERF_UPDATE,
+    PERF_VERIFY,
+    PERF_BASE,
+    PERF_CLOSE_SEND,
+    PERF_HANDLE_CLOSE,
+    PERF_HANDLE_CLOSE_ACK,
+    PERF_CLOSE_COMPLETE,
+    PERF_DSA_VERIFY_IMPL,
+    PERF_RSA_VERIFY_IMPL,
+    /* The firewall only uses the sensors given above, hence it
+     * has a separate PERF_MAX. */
+    PERF_MAX_FIREWALL,
+    PERF_DH_CREATE,
+    PERF_SIGN,
+    PERF_DSA_SIGN_IMPL,
+    PERF_I1_SEND,
+    PERF_RSA_SIGN_IMPL,
+    PERF_STARTUP,
+    /* Number of sensors for the HIP daemon. */
+    PERF_MAX
 };
 
 perf_set_t *perf_set;

=== modified file 'lib/core/prefix.c'
--- lib/core/prefix.c   2010-08-19 09:32:20 +0000
+++ lib/core/prefix.c   2010-10-18 17:44:31 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This file contains address-related utility functions to
  * manipulate LSI/HIT prefixes
  *

=== modified file 'lib/core/prefix.h'
--- lib/core/prefix.h   2010-08-19 09:32:20 +0000
+++ lib/core/prefix.h   2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'lib/core/protodefs.h'
--- lib/core/protodefs.h        2010-09-03 11:40:19 +0000
+++ lib/core/protodefs.h        2010-11-09 16:37:54 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -24,7 +22,9 @@
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
  */
-/** @file
+
+/**
+ * @file
  * This file defines a Host Identity Protocol (HIP) header and parameter
  * related constants and structures.
  */
@@ -504,9 +504,10 @@
  * importantantly, these are <span style="color:#f00;">the only values allowed
  * in that field.</span> Do not put any other bits on wire in the Controls
  * field.
- * @note Do not confuse these values with HIP host association ontrol values.
+ * @note Do not confuse these values with HIP host association Control values.
  * @{
  */
+#define HIP_PACKET_CTRL_NON              0x0000 /**< HIP packet with empty 
Controls field */
 #define HIP_PACKET_CTRL_ANON             0x0001 /**< HIP packet Controls value 
*/
 /* unused, was HIP_PACKET_CTRL_BLIND 0x0004 */
 /* @} */
@@ -579,7 +580,6 @@
 typedef struct hip_hadb_xmit_func_set hip_xmit_func_set_t;
 typedef struct hip_ipsec_func_set hip_ipsec_func_set_t;
 typedef struct hip_common hip_common_t;
-typedef struct hip_tlv_common hip_tlv_common_t;
 
 struct hip_crypto_key {
     uint8_t key[HIP_MAX_KEY_LEN];
@@ -1086,18 +1086,24 @@
 } __attribute__ ((packed));
 
 /**
- * Structure used during packet handling to store the incoming message,
- * source address, destination address, the used ports, the host association
- * database entry and a flag indicating the packet handling should be aborted.
+ * A data structure for storing the source and destination ports of a packet.
+ */
+struct hip_portpair_t {
+    in_port_t src_port;     /**< The source port of an incoming packet. */
+    in_port_t dst_port;     /**< The destination port of an incoming packet. */
+};
+
+/**
+ * Structure used to pass information around during packet handling.
  */
 struct hip_packet_context {
-    struct hip_common         *input_msg;
-    struct hip_common         *output_msg;
-    struct in6_addr           *src_addr;
-    struct in6_addr           *dst_addr;
-    struct hip_stateless_info *msg_ports;
-    struct hip_hadb_state     *hadb_entry;
-    uint8_t                    error;
+    struct hip_common         *input_msg;  /**< Incoming message. */
+    struct hip_common         *output_msg; /**< Outgoing message. */
+    struct in6_addr            src_addr;   /**< Packet origin. */
+    struct in6_addr            dst_addr;   /**< Packet destination. */
+    struct hip_portpair_t      msg_ports;  /**< Used ports. */
+    struct hip_hadb_state     *hadb_entry; /**< Host association database 
entry. */
+    uint8_t                    error;      /**< Abort further processing if 
not 0 */
 };
 
 

=== modified file 'lib/core/solve.c'
--- lib/core/solve.c    2010-08-19 10:43:06 +0000
+++ lib/core/solve.c    2010-10-18 17:44:31 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * @brief HIP computation puzzle solving algorithms
  *
  * @author Miika Komu <miika@xxxxxx>

=== modified file 'lib/core/solve.h'
--- lib/core/solve.h    2010-08-20 14:34:13 +0000
+++ lib/core/solve.h    2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'lib/core/state.h'
--- lib/core/state.h    2010-10-19 21:33:03 +0000
+++ lib/core/state.h    2010-11-09 16:37:54 +0000
@@ -1,8 +1,5 @@
-/** @file
- * This file defines Host Identity Protocol (HIP) header and parameter related
- * constants and structures.
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -26,6 +23,12 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
+/**
+ * @file
+ * This file defines Host Identity Protocol (HIP) header and parameter related
+ * constants and structures.
+ */
+
 #ifndef HIP_LIB_CORE_STATE_H
 #define HIP_LIB_CORE_STATE_H
 
@@ -111,15 +114,6 @@
 } hip_hastate_t;
 
 /**
- * A data structure for storing the source and destination ports of an incoming
- * packet.
- */
-typedef struct hip_stateless_info {
-    in_port_t src_port;     /**< The source port of an incoming packet. */
-    in_port_t dst_port;     /**< The destination port of an incoming packet. */
-} hip_portpair_t;
-
-/**
  * A data structure for handling retransmission. Used inside host association
  * database entries.
  */

=== modified file 'lib/core/statistics.c'
--- lib/core/statistics.c       2010-09-03 11:40:19 +0000
+++ lib/core/statistics.c       2010-11-09 16:37:54 +0000
@@ -1,6 +1,5 @@
-/** @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -22,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This file defines helper function for statistical computations
  *
  * @author Rene Hummen

=== modified file 'lib/core/statistics.h'
--- lib/core/statistics.h       2010-07-14 16:01:50 +0000
+++ lib/core/statistics.h       2010-10-15 15:29:14 +0000
@@ -1,6 +1,5 @@
-/** @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -22,9 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Header file for statistics.c
- *
+ */
+
+/**
+ * @file
  * @author Rene Hummen
  */
 

=== modified file 'lib/core/straddr.c'
--- lib/core/straddr.c  2010-07-14 15:58:20 +0000
+++ lib/core/straddr.c  2010-10-19 23:18:00 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * @brief Conversion functions from string to address and vice versa
  *
  * @author Miika Komu <miika@xxxxxx>
@@ -31,30 +32,28 @@
 
 #define _BSD_SOURCE
 
-#include <ctype.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <openssl/evp.h>
+#include <stdio.h>      // sprintf()
+#include <arpa/inet.h>  // inet_pton()
 
-#include "config.h"
-#include "debug.h"
-#include "ife.h"
-#include "prefix.h"
+#include "debug.h"      // HIP_DEBUG()
+#include "prefix.h"     // IPV4_TO_IPV6_MAP()
 #include "straddr.h"
 
 /**
- * convert a binary IPv6 address to a string
+ * Convert a binary IPv6 address to a hexadecimal string representation of the
+ * form 0011:2233:4455:6677:8899:AABB:CCDD:EEFF terminated by a null character.
  *
- * @param in6 the IPv6 address to convert
- * @param buf a preallocated buffer where the string will be stored
- * @return a pointer to the buf
+ * @param in6 a pointer to a binary IPv6 address.
+ * @param buf a pointer to a buffer to write the string representation to. The
+ *  result of passing a buffer that is too short to hold the string
+ *  representation is undefined.
+ * @return The function returns a pointer to the output buffer buf if the
+ *  address is successfully converted. It returns a negative value if in6 is
+ *  NULL or buf is NULL.
  */
-char *hip_in6_ntop(const struct in6_addr *in6, char *buf)
+char *hip_in6_ntop(const struct in6_addr *const in6, char *const buf)
 {
-    if (!buf) {
+    if (!in6 || !buf) {
         return NULL;
     }
     sprintf(buf,
@@ -67,137 +66,37 @@
 }
 
 /**
- * convert a string into a binary IPv4 address (a wrapper for inet_pton())
- *
- * @param str the string to convert
- * @param ip an output argument that will contain a binary IPv4 calculated
- *        from the @c str
- * @return zero on success and negative on error
- */
-int convert_string_to_address_v4(const char *str, struct in_addr *ip)
-{
-    int ret = 0, err = 0;
-
-    ret = inet_pton(AF_INET, str, ip);
-    HIP_IFEL((ret < 0 && errno == EAFNOSUPPORT), -1,
-             "inet_pton: not a valid address family\n");
-    HIP_IFEL((ret == 0), -1,
-             "inet_pton: %s: not a valid network address\n", str);
-out_err:
-    return err;
-}
-
-/**
- * Convert a string to an IPv6 address. This function can handle
- * also IPv6 mapped addresses.
- *
- * @param str the string to convert
- * @param ip6 An output argument that will contain a binary IPv4 calculated
- *        from the @c str. Possibly in IPv6 mapped format.
- * @return zero on success or negative on error
- */
-int convert_string_to_address(const char *str,
-                              struct in6_addr *ip6)
-{
-    int ret = 0, err = 0;
-    struct in_addr ip4;
-
-    ret = inet_pton(AF_INET6, str, ip6);
-    HIP_IFEL((ret < 0 && errno == EAFNOSUPPORT), -1,
-             "\"%s\" is not of valid address family.\n", str);
-    if (ret > 0) {
-        /* IPv6 address conversion was ok */
-        goto out_err;
-    }
-
-    /* Might be an ipv4 address (ret == 0). Lets catch it here. */
-    err = convert_string_to_address_v4(str, &ip4);
-    if (err) {
-        goto out_err;
-    }
-
-    IPV4_TO_IPV6_MAP(&ip4, ip6);
-    HIP_DEBUG("Mapped v4 to v6.\n");
-    HIP_DEBUG_IN6ADDR("mapped v6", ip6);
-
-out_err:
-    return err;
-}
-
-/**
- * convert a string containing upper case characters to lower case
- *
- * @param to the result of the conversion (minimum length @c count)
- * @param from a string possibly containing upper case characters
- * @param count count
- * @return zero on success or negative on failure
- */
-int hip_string_to_lowercase(char *to, const char *from, const size_t count)
-{
-    unsigned i;
-
-    if (to == NULL || from == NULL || count == 0) {
-        return -1;
-    }
-
-    for (i = 0; i < count; i++) {
-        if (isalpha(from[i])) {
-            to[i] = tolower(from[i]);
+ * Convert a string representation of an IPv6 or IPv4 address to a struct
+ * in6_addr.
+ * If the string contains an IPv4 address, it is converted to its
+ * IPv6-compatible mapping.
+ *
+ * @param str points to the string to convert.
+ * @param ip6 points to a buffer where the function stores the binary address
+ *  if it could be converted.
+ * @return The return value is 0 if the conversion succeeds. It is a
+ *  negative value if str or ip6 are NULL or if str contains neither a
+ *  parseable IPv6 or IPv4 address.
+ */
+int hip_convert_string_to_address(const char *const str,
+                                  struct in6_addr *const ip6)
+{
+    if (str && ip6) {
+        if (inet_pton(AF_INET6, str, ip6) == 1) {
+            /* IPv6 address conversion was ok */
+            return 0;
         } else {
-            to[i] = from[i];
-        }
-    }
-    return 0;
-}
-
-/**
- * test if a given string contains a positive integer
- *
- * @param string the string to test
- * @return zero if the string is digit or negative otherwise
- */
-int hip_string_is_digit(const char *string)
-{
-    if (string == NULL) {
-        return -1;
-    }
-
-    int i = 0;
-
-    while (string[i] != '\0') {
-        if (!isdigit(string[i])) {
-            return -1;
-        }
-        i++;
-    }
-    return 0;
-}
-
-
-/**
- * encode the given content to Base64
- *
- * @param buf Pointer to contents to be encoded
- * @param len How long is the first parameter in bytes
- *
- * @return Returns a pointer to encoded content or NULL on error
- */
-unsigned char *base64_encode(unsigned char *buf, unsigned int len)
-{
-    unsigned char *ret;
-    unsigned int b64_len;
-
-    b64_len = (((len + 2) / 3) * 4) + 1;
-    ret     = malloc(b64_len);
-    if (ret == NULL) {
-        goto out_err;
-    }
-    EVP_EncodeBlock(ret, buf, len);
-    return ret;
-out_err:
-    if (ret) {
-        free(ret);
-    }
-    return NULL;
-}
-
+            struct in_addr ip4;
+
+            /* Might be an ipv4 address (ret == 0). Lets catch it here. */
+            if (inet_pton(AF_INET, str, &ip4) == 1) {
+                IPV4_TO_IPV6_MAP(&ip4, ip6);
+                HIP_DEBUG("Mapped v4 to v6.\n");
+                HIP_DEBUG_IN6ADDR("mapped v6", ip6);
+                return 0;
+            }
+        }
+    }
+
+    return -1;
+}

=== modified file 'lib/core/straddr.h'
--- lib/core/straddr.h  2010-07-04 17:54:18 +0000
+++ lib/core/straddr.h  2010-10-19 12:08:54 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -31,11 +29,8 @@
 #include <sys/types.h>
 #include <netinet/in.h>
 
-int convert_string_to_address_v4(const char *str, struct in_addr *ip);
-int convert_string_to_address(const char *str, struct in6_addr *ip6);
-char *hip_in6_ntop(const struct in6_addr *in6, char *buf);
-int hip_string_to_lowercase(char *to, const char *from, const size_t count);
-int hip_string_is_digit(const char *string);
-unsigned char *base64_encode(unsigned char *, unsigned int);
+char *hip_in6_ntop(const struct in6_addr *const in6, char *const buf);
+int hip_convert_string_to_address(const char *const str,
+                                  struct in6_addr *const ip6);
 
 #endif /* HIP_LIB_CORE_STRADDR_H */

=== modified file 'lib/core/transform.c'
--- lib/core/transform.c        2010-08-19 09:32:20 +0000
+++ lib/core/transform.c        2010-10-18 17:44:31 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * @brief Transform related functions for HIP
  *
  * @author Miika Komu <miika@xxxxxx>

=== modified file 'lib/core/transform.h'
--- lib/core/transform.h        2010-08-19 09:32:20 +0000
+++ lib/core/transform.h        2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'lib/core/util.h'
--- lib/core/util.h     2010-08-19 18:18:57 +0000
+++ lib/core/util.h     2010-10-15 15:17:22 +0000
@@ -1,4 +1,30 @@
-/** @file
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file
  * utility functions
  * @author Diego Biurrun <diego@xxxxxxxxxx>
  */

=== modified file 'lib/modularization/lmod.c'
--- lib/modularization/lmod.c   2010-08-29 16:24:14 +0000
+++ lib/modularization/lmod.c   2010-10-27 11:11:20 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,12 +21,15 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * @brief The main source file for libmodularization (lmod).
  *
  * @author Tim Just <tim.just@xxxxxxxxxxxxxx>
- *
  */
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -275,7 +276,7 @@
                                  void *entry,
                                  const uint16_t priority)
 {
-    int            index    = 0;
+    int idx = 0;
     hip_ll_t      *new_list = NULL;
     hip_ll_node_t *iter     = NULL;
 
@@ -297,11 +298,11 @@
         } else if (priority < ((struct function *) iter->ptr)->priority) {
             break;
         } else {
-            index++;
+            idx++;
         }
     }
 
-    hip_ll_add(list, index, entry);
+    hip_ll_add(list, idx, entry);
 
     return list;
 }
@@ -317,8 +318,8 @@
  */
 int lmod_unregister_function(hip_ll_t *list, const void *function)
 {
-    int            index = 0;
-    hip_ll_node_t *iter  = NULL;
+    int idx = 0;
+    hip_ll_node_t *iter = NULL;
 
     if (!list) {
         return -1;
@@ -326,10 +327,10 @@
 
     while ((iter = hip_ll_iterate(list, iter))) {
         if (function == ((struct function *) iter->ptr)->func_ptr) {
-            hip_ll_del(list, index, free);
+            hip_ll_del(list, idx, free);
             break;
         }
-        index++;
+        idx++;
     }
 
     return 0;
@@ -417,14 +418,14 @@
  */
 static int lmod_packet_type_exists(const uint16_t packet_type)
 {
-    int            index = 0;
-    hip_ll_node_t *iter  = NULL;
+    int idx = 0;
+    hip_ll_node_t *iter = NULL;
 
     while ((iter = hip_ll_iterate(&packet_types, iter))) {
         if (packet_type == ((struct packet_type *) iter->ptr)->num) {
-            return index;
+            return idx;
         } else {
-            index++;
+            idx++;
         }
     }
 
@@ -446,10 +447,10 @@
 int lmod_register_packet_type(const uint16_t packet_type,
                               const char *identifier)
 {
-    int                 index          = 0;
-    size_t              identifier_len = 0;
-    hip_ll_node_t      *iter           = NULL;
-    struct packet_type *new_entry      = NULL;
+    int idx = 0;
+    size_t identifier_len = 0;
+    hip_ll_node_t      *iter      = NULL;
+    struct packet_type *new_entry = NULL;
 
     if (!identifier || (lmod_packet_type_exists(packet_type) != -1)) {
         return -1;
@@ -473,11 +474,11 @@
         } else if (packet_type < ((struct packet_type *) iter->ptr)->num) {
             break;
         } else {
-            index++;
+            idx++;
         }
     }
 
-    hip_ll_add(&packet_types, index, new_entry);
+    hip_ll_add(&packet_types, idx, new_entry);
 
     return 0;
 }

=== modified file 'lib/modularization/lmod.h'
--- lib/modularization/lmod.h   2010-07-04 17:54:18 +0000
+++ lib/modularization/lmod.h   2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,12 +21,13 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
- * @brief The main header file for libmodularization.
- *
+ */
+
+/**
+ * @file
  * @author Tim Just <tim.just@xxxxxxxxxxxxxx>
- *
  */
+
 #ifndef HIP_LIB_MODULARIZATION_LMOD_H
 #define HIP_LIB_MODULARIZATION_LMOD_H
 

=== modified file 'lib/tool/lutil.c'
--- lib/tool/lutil.c    2010-06-01 15:13:06 +0000
+++ lib/tool/lutil.c    2010-10-18 16:48:52 +0000
@@ -1,8 +1,7 @@
 /**
  * @file
  *
- * Distributed under
- * <a href="http://www.gnu.org/licenses/gpl2.txt";>GNU/GPL</a>
+ * Distributed under <a href="http://www.gnu.org/licenses/gpl2.txt";>GNU/GPL</a>
  *
  * @brief Utilities borrowed from libinet6.
  */

=== modified file 'lib/tool/lutil.h'
--- lib/tool/lutil.h    2010-06-01 15:13:06 +0000
+++ lib/tool/lutil.h    2010-10-18 16:48:52 +0000
@@ -1,8 +1,8 @@
-/** @file
- * A header file for lutil.c. Imported from libinet6.
+/**
+ * @file
+ * Imported from libinet6.
  *
- * Distributed under
- * <a href="http://www.gnu.org/licenses/gpl2.txt";>GNU/GPL</a>
+ * Distributed under <a href="http://www.gnu.org/licenses/gpl2.txt";>GNU/GPL</a>
  */
 
 #ifndef HIP_LIB_TOOL_LUTIL_H

=== modified file 'lib/tool/nlink.c'
--- lib/tool/nlink.c    2010-08-29 16:24:14 +0000
+++ lib/tool/nlink.c    2010-09-20 14:07:02 +0000
@@ -1417,114 +1417,3 @@
     return err;
 }
 
-/**
- * fill the port numbers for the UDP tunnel for IPsec
- *
- * @param encap xfrm_encap_tmpl structure
- * @param sport source port
- * @param dport destination port
- * @param oa the destination address of the tunnel in IPv6-mapped format
- * @return 0
- */
-int xfrm_fill_encap(struct xfrm_encap_tmpl *encap,
-                    int sport,
-                    int dport,
-                    const struct in6_addr *oa)
-{
-    encap->encap_type  = HIP_UDP_ENCAP_ESPINUDP;
-    encap->encap_sport = htons(sport);
-    encap->encap_dport = htons(dport);
-    encap->encap_oa.a4 = oa->s6_addr32[3];
-    return 0;
-}
-
-/**
- * Fill in the selector. Selector is bound to HITs.
- *
- * @param sel pointer to xfrm_selector to be filled in
- * @param id_our Source HIT or LSI, if the last is defined
- * @param id_peer Peer HIT or LSI, if the last is defined
- * @param proto inclusive protocol filter (zero for any protocol)
- * @param id_prefix Length of the identifier's prefix
- * @param preferred_family address family filter (AF_INET6 for HITs)
- * @return 0
- */
-int xfrm_fill_selector(struct xfrm_selector *sel,
-                       const struct in6_addr *id_our,
-                       const struct in6_addr *id_peer,
-                       uint8_t proto, uint8_t id_prefix,
-                       int preferred_family)
-{
-    struct in_addr in_id_our, in_id_peer;
-
-    if (IN6_IS_ADDR_V4MAPPED(id_our)) {
-        sel->family = AF_INET;
-        IPV6_TO_IPV4_MAP(id_our, &in_id_our);
-        IPV6_TO_IPV4_MAP(id_peer, &in_id_peer);
-        memcpy(&sel->daddr, &in_id_our, sizeof(sel->daddr));
-        memcpy(&sel->saddr, &in_id_peer, sizeof(sel->saddr));
-    } else {
-        sel->family = preferred_family;
-        memcpy(&sel->daddr, id_peer, sizeof(sel->daddr));
-        memcpy(&sel->saddr, id_our, sizeof(sel->saddr));
-    }
-
-    if (proto) {
-        HIP_DEBUG("proto = %d\n", proto);
-        sel->proto = proto;
-    }
-
-    sel->prefixlen_d = id_prefix;
-    sel->prefixlen_s = id_prefix;
-
-    return 0;
-}
-
-/**
- * initialize the lft
- *
- * @param lft pointer to the lft struct to be initialized
- *
- * @return 0
- */
-int xfrm_init_lft(struct xfrm_lifetime_cfg *lft)
-{
-    lft->soft_byte_limit   = XFRM_INF;
-    lft->hard_byte_limit   = XFRM_INF;
-    lft->soft_packet_limit = XFRM_INF;
-    lft->hard_packet_limit = XFRM_INF;
-
-    return 0;
-}
-
-/**
- * parse a crypto algorithm name and its key into an xfrm_algo structure
- *
- * @param alg the resulting xfrm_algo structure (caller allocates)
- * @param name the name of the crypto algorithm
- * @param key the key for the given algorithm
- * @param key_len the length of the key in bits
- * @param max maximum size for a key in the xfrm_algo structure
- * @return zero
- */
-int xfrm_algo_parse(struct xfrm_algo *alg, const char *name,
-                    const unsigned char *key, int key_len, int max)
-{
-    int len  = 0;
-    int slen = key_len;
-
-    strncpy(alg->alg_name, name, sizeof(alg->alg_name));
-
-    len = slen;
-    if (len > 0) {
-        if (len > max) {
-            HIP_ERROR("\"ALGOKEY\" makes buffer overflow\n", key);
-            return -1;
-        }
-        memcpy(alg->alg_key, key, key_len * 8);
-    }
-
-    alg->alg_key_len = len * 8;
-
-    return 0;
-}

=== modified file 'lib/tool/nlink.h'
--- lib/tool/nlink.h    2010-06-08 14:48:16 +0000
+++ lib/tool/nlink.h    2010-09-20 14:07:02 +0000
@@ -92,18 +92,4 @@
                     const struct in6_addr *dst_addr, char *idev, char *odev,
                     int family, struct idxmap **idxmap);
 
-int xfrm_init_lft(struct xfrm_lifetime_cfg *lft);
-int xfrm_fill_selector(struct xfrm_selector *sel,
-                       const struct in6_addr *id_our,
-                       const struct in6_addr *id_peer,
-                       uint8_t proto, uint8_t id_prefix,
-                       int preferred_family);
-int xfrm_fill_encap(struct xfrm_encap_tmpl *encap,
-                    int sport,
-                    int dport,
-                    const struct in6_addr *oa);
-
-int xfrm_algo_parse(struct xfrm_algo *alg, const char *name,
-                    const unsigned char *key, int key_len, int max);
-
 #endif /* HIP_LIB_TOOL_NLINK_H */

=== modified file 'lib/tool/xfrmapi.c'
--- lib/tool/xfrmapi.c  2010-07-16 18:56:20 +0000
+++ lib/tool/xfrmapi.c  2010-09-20 14:13:40 +0000
@@ -71,6 +71,119 @@
 
 
 /**
+ * fill the port numbers for the UDP tunnel for IPsec
+ *
+ * @param encap xfrm_encap_tmpl structure
+ * @param sport source port
+ * @param dport destination port
+ * @param oa the destination address of the tunnel in IPv6-mapped format
+ * @return 0
+ */
+static int hip_xfrm_fill_encap(struct xfrm_encap_tmpl *encap,
+                               const int sport,
+                               const int dport,
+                               const struct in6_addr *oa)
+{
+    encap->encap_type  = HIP_UDP_ENCAP_ESPINUDP;
+    encap->encap_sport = htons(sport);
+    encap->encap_dport = htons(dport);
+    encap->encap_oa.a4 = oa->s6_addr32[3];
+    return 0;
+}
+
+/**
+ * Fill in the selector. Selector is bound to HITs.
+ *
+ * @param sel pointer to xfrm_selector to be filled in
+ * @param id_our Source HIT or LSI, if the last is defined
+ * @param id_peer Peer HIT or LSI, if the last is defined
+ * @param proto inclusive protocol filter (zero for any protocol)
+ * @param id_prefix Length of the identifier's prefix
+ * @param preferred_family address family filter (AF_INET6 for HITs)
+ * @return 0
+ */
+static int hip_xfrm_fill_selector(struct xfrm_selector *sel,
+                                  const struct in6_addr *id_our,
+                                  const struct in6_addr *id_peer,
+                                  const uint8_t proto, const uint8_t id_prefix,
+                                  const int preferred_family)
+{
+    struct in_addr in_id_our, in_id_peer;
+
+    if (IN6_IS_ADDR_V4MAPPED(id_our)) {
+        sel->family = AF_INET;
+        IPV6_TO_IPV4_MAP(id_our, &in_id_our);
+        IPV6_TO_IPV4_MAP(id_peer, &in_id_peer);
+        memcpy(&sel->daddr, &in_id_our, sizeof(sel->daddr));
+        memcpy(&sel->saddr, &in_id_peer, sizeof(sel->saddr));
+    } else {
+        sel->family = preferred_family;
+        memcpy(&sel->daddr, id_peer, sizeof(sel->daddr));
+        memcpy(&sel->saddr, id_our, sizeof(sel->saddr));
+    }
+
+    if (proto) {
+        HIP_DEBUG("proto = %d\n", proto);
+        sel->proto = proto;
+    }
+
+    sel->prefixlen_d = id_prefix;
+    sel->prefixlen_s = id_prefix;
+
+    return 0;
+}
+
+/**
+ * initialize the lft
+ *
+ * @param lft pointer to the lft struct to be initialized
+ *
+ * @return 0
+ */
+static int hip_xfrm_init_lft(struct xfrm_lifetime_cfg *lft)
+{
+    lft->soft_byte_limit   = XFRM_INF;
+    lft->hard_byte_limit   = XFRM_INF;
+    lft->soft_packet_limit = XFRM_INF;
+    lft->hard_packet_limit = XFRM_INF;
+
+    return 0;
+}
+
+/**
+ * parse a crypto algorithm name and its key into an xfrm_algo structure
+ *
+ * @param alg the resulting xfrm_algo structure (caller allocates)
+ * @param name the name of the crypto algorithm
+ * @param key the key for the given algorithm
+ * @param key_len the length of the key in bits
+ * @param max maximum size for a key in the xfrm_algo structure
+ * @return zero
+ */
+static int hip_xfrm_algo_parse(struct xfrm_algo *alg, const char *name,
+                               const unsigned char *key, const int key_len,
+                               const int max)
+{
+    int len  = 0;
+    int slen = key_len;
+
+    strncpy(alg->alg_name, name, sizeof(alg->alg_name));
+
+    len = slen;
+    if (len > 0) {
+        if (len > max) {
+            HIP_ERROR("\"ALGOKEY\" makes buffer overflow\n", key);
+            return -1;
+        }
+        memcpy(alg->alg_key, key, key_len * 8);
+    }
+
+    alg->alg_key_len = len * 8;
+
+    return 0;
+}
+
+/**
  * modify a Security Policy
  * @param cmd command. %XFRM_MSG_NEWPOLICY | %XFRM_MSG_UPDPOLICY
  * @param id_our Source ID or LSI
@@ -110,14 +223,14 @@
     req.n.nlmsg_flags = NLM_F_REQUEST | flags;
     req.n.nlmsg_type  = cmd;
 
-    xfrm_init_lft(&req.xpinfo.lft);
+    hip_xfrm_init_lft(&req.xpinfo.lft);
 
     /* Direction */
     req.xpinfo.dir = dir;
 
     /* SELECTOR <--> HITs  SELECTOR <--> LSIs*/
-    HIP_IFE(xfrm_fill_selector(&req.xpinfo.sel, id_peer, id_our, 0,
-                               id_prefix, preferred_family), -1);
+    HIP_IFE(hip_xfrm_fill_selector(&req.xpinfo.sel, id_peer, id_our, 0,
+                                   id_prefix, preferred_family), -1);
 
     /* TEMPLATE */
     tmpl = (struct xfrm_user_tmpl *) ((char *) tmpls_buf);
@@ -257,8 +370,8 @@
     req.xpid.dir      = dir;
 
     /* SELECTOR <--> HITs */
-    HIP_IFE(xfrm_fill_selector(&req.xpid.sel, hit_peer, hit_our, 0,
-                               hit_prefix, preferred_family), -1);
+    HIP_IFE(hip_xfrm_fill_selector(&req.xpid.sel, hit_peer, hit_our, 0,
+                                   hit_prefix, preferred_family), -1);
     HIP_IFEL((netlink_talk(rth, &req.n, 0, 0, NULL, NULL, NULL) < 0), -1,
              "No associated policies to be deleted\n");
 
@@ -332,7 +445,7 @@
     req.n.nlmsg_flags   = NLM_F_REQUEST;
     req.n.nlmsg_type    = cmd;
 
-    xfrm_init_lft(&req.xsinfo.lft);
+    hip_xfrm_init_lft(&req.xsinfo.lft);
 
     req.xsinfo.mode     = XFRM_MODE_BEET;
     req.xsinfo.id.proto = IPPROTO_ESP;
@@ -340,12 +453,14 @@
     req.xsinfo.id.spi   = htonl(spi);
 
     /* Selector */
-    HIP_IFE(xfrm_fill_selector(&req.xsinfo.sel, src_id, dst_id,
-                               0, hip_xfrmapi_sa_default_prefix,
-                               AF_INET6), -1);
+    HIP_IFE(hip_xfrm_fill_selector(&req.xsinfo.sel, src_id, dst_id,
+                                   0, hip_xfrmapi_sa_default_prefix,
+                                   AF_INET6), -1);
     if (req.xsinfo.family == AF_INET && (sport || dport)) {
-        xfrm_fill_encap(&encap, (sport ? sport : hip_get_local_nat_udp_port()),
-                        (dport ? dport : hip_get_peer_nat_udp_port()), saddr);
+        hip_xfrm_fill_encap(&encap,
+                            (sport ? sport : hip_get_local_nat_udp_port()),
+                            (dport ? dport : hip_get_peer_nat_udp_port()),
+                            saddr);
         HIP_IFE(addattr_l(&req.n, sizeof(req.buf), XFRMA_ENCAP,
                           &encap, sizeof(encap)), -1);
     }
@@ -366,9 +481,9 @@
 
         /* XFRMA_ALG_AUTH */
         memset(&alg, 0, sizeof(alg));
-        HIP_IFE(xfrm_algo_parse((void *) &alg, a_name,
-                                authkey->key, authkey_len,
-                                sizeof(alg.buf)), -1);
+        HIP_IFE(hip_xfrm_algo_parse((void *) &alg, a_name,
+                                    authkey->key, authkey_len,
+                                    sizeof(alg.buf)), -1);
         len = sizeof(struct xfrm_algo) + alg.algo.alg_key_len;
 
         HIP_IFE((addattr_l(&req.n, sizeof(req.buf), XFRMA_ALG_AUTH,
@@ -376,9 +491,9 @@
 
         /* XFRMA_ALG_CRYPT */
         memset(&alg, 0, sizeof(alg));
-        HIP_IFE(xfrm_algo_parse((void *) &alg, e_name,
-                                enckey->key, enckey_len,
-                                sizeof(alg.buf)), -1);
+        HIP_IFE(hip_xfrm_algo_parse((void *) &alg, e_name,
+                                    enckey->key, enckey_len,
+                                    sizeof(alg.buf)), -1);
 
         len = sizeof(struct xfrm_algo) + alg.algo.alg_key_len;
 
@@ -439,9 +554,10 @@
     /** @todo Fill in information for UDP-NAT SAs. */
     if (req.xsid.family == AF_INET && (sport || dport)) {
         HIP_DEBUG("FILLING UDP Port info while deleting\n");
-        xfrm_fill_encap(&encap, (sport ? sport : hip_get_local_nat_udp_port()),
-                        (dport ? dport : hip_get_peer_nat_udp_port()),
-                        peer_addr);
+        hip_xfrm_fill_encap(&encap,
+                            (sport ? sport : hip_get_local_nat_udp_port()),
+                            (dport ? dport : hip_get_peer_nat_udp_port()),
+                            peer_addr);
         HIP_IFE(addattr_l(&req.n, sizeof(req.buf), XFRMA_ENCAP,
                           &encap, sizeof(encap)), -1);
     }

=== modified file 'lib/tool/xfrmapi.h'
--- lib/tool/xfrmapi.h  2010-06-08 19:54:28 +0000
+++ lib/tool/xfrmapi.h  2010-09-09 01:12:24 +0000
@@ -31,7 +31,7 @@
 void hip_xfrm_set_nl_ipsec(struct rtnl_handle *nl_ipsec);
 int hip_xfrm_dst_init(struct in6_addr *dst_hit, struct in6_addr *dst_addr);
 int hip_xfrm_update(hip_hit_t *hit, hip_hit_t *hit2, struct in6_addr *addr,
-                    uint32_t spi, int state, int dir, hip_portpair_t *sa_info);
+                    uint32_t spi, int state, int dir, struct hip_portpair_t 
*sa_info);
 int hip_xfrm_delete(hip_hit_t *hit, uint32_t spi, int dir);
 
 /* Setups the SA (with a given SPI if so said) */

=== modified file 'modules/esp_tokens/hipd/esp_prot_anchordb.c'
--- modules/esp_tokens/hipd/esp_prot_anchordb.c 2010-09-03 11:40:19 +0000
+++ modules/esp_tokens/hipd/esp_prot_anchordb.c 2010-11-09 16:37:54 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This implementation stores anchor elements to be used as references to
  * the hash structures stored in the BEX store of the hipfw. The elements
  * maintained here should be used for the insertion of new anchor elements
@@ -32,7 +33,6 @@
  * @brief Stores anchor elements to be used for the esp protection
  *
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #include <stdint.h>

=== modified file 'modules/esp_tokens/hipd/esp_prot_anchordb.h'
--- modules/esp_tokens/hipd/esp_prot_anchordb.h 2010-09-03 11:40:19 +0000
+++ modules/esp_tokens/hipd/esp_prot_anchordb.h 2010-11-09 16:37:54 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -28,11 +26,13 @@
  * the hash structures stored in the BEX store of the hipfw. The elements
  * maintained here should be used for the insertion of new anchor elements
  * during HIP BEX.
- *
+ */
+
+/**
+ * @file
  * @brief Stores anchor elements to be used for the esp protection
  *
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #ifndef HIP_HIPD_ESP_PROT_ANCHORDB_H

=== modified file 'modules/esp_tokens/hipd/esp_prot_hipd_msg.c'
--- modules/esp_tokens/hipd/esp_prot_hipd_msg.c 2010-10-19 21:29:10 +0000
+++ modules/esp_tokens/hipd/esp_prot_hipd_msg.c 2010-11-09 16:37:54 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,14 +21,16 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * hipd messages to the hipfw and additional parameters for BEX and
  * UPDATE messages.
  *
  * @brief Messaging with hipfw and other HIP instances
  *
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #include <errno.h>

=== modified file 'modules/esp_tokens/hipd/esp_prot_hipd_msg.h'
--- modules/esp_tokens/hipd/esp_prot_hipd_msg.h 2010-09-03 11:40:19 +0000
+++ modules/esp_tokens/hipd/esp_prot_hipd_msg.h 2010-11-09 16:37:54 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,14 +21,16 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * hipd messages to the hipfw and additional parameters for BEX and
  * UPDATE messages.
  *
  * @brief Messaging with hipfw and other HIP instances
  *
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #ifndef HIP_HIPD_ESP_PROT_HIPD_MSG_H

=== modified file 'modules/esp_tokens/hipd/esp_prot_light_update.c'
--- modules/esp_tokens/hipd/esp_prot_light_update.c     2010-09-08 15:54:51 
+0000
+++ modules/esp_tokens/hipd/esp_prot_light_update.c     2010-11-09 16:37:54 
+0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,14 +21,16 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * Provides messaging functionality required for HHL-based anchor
  * element updates.
  *
  * @brief Messaging required for HHL-based anchor element updates
  *
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #include <errno.h>
@@ -285,8 +285,8 @@
 
         // send ACK
         esp_prot_send_light_ack(ctx->hadb_entry,
-                                ctx->dst_addr,
-                                ctx->src_addr,
+                                &ctx->dst_addr,
+                                &ctx->src_addr,
                                 spi);
     } else if (ack != NULL) {
         /********** ACK ***********/

=== modified file 'modules/esp_tokens/hipd/esp_prot_light_update.h'
--- modules/esp_tokens/hipd/esp_prot_light_update.h     2010-09-03 11:40:19 
+0000
+++ modules/esp_tokens/hipd/esp_prot_light_update.h     2010-11-09 16:37:54 
+0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,14 +21,16 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ *@file
  * Provides messaging functionality required for HHL-based anchor
  * element updates.
  *
  * @brief Messaging required for HHL-based anchor element updates
  *
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #ifndef HIP_HIPD_ESP_PROT_LIGHT_UPDATE_H

=== modified file 'modules/esp_tokens/lib/esp_prot_common.c'
--- modules/esp_tokens/lib/esp_prot_common.c    2010-09-03 11:40:19 +0000
+++ modules/esp_tokens/lib/esp_prot_common.c    2010-11-09 16:37:54 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This implementation provides functionality for the ESP protection in
  * hipd and hipfw. It also defines necessary TPA parameters used by both
  * hipfw and hipd.
@@ -31,7 +32,6 @@
  * @brief Provides common functionality for the ESP protection in hipd and 
hipfw
  *
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #include "esp_prot_common.h"

=== modified file 'modules/esp_tokens/lib/esp_prot_common.h'
--- modules/esp_tokens/lib/esp_prot_common.h    2010-09-03 11:40:19 +0000
+++ modules/esp_tokens/lib/esp_prot_common.h    2010-11-09 16:37:54 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * API for the  functionality for the ESP protection in
  * hipd and hipfw. It also defines necessary TPA parameters used by both
  * hipfw and hipd.
@@ -31,7 +32,6 @@
  * @brief Provides common functionality for the ESP protection in hipd and 
hipfw
  *
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #ifndef HIP_LIB_CORE_ESP_PROT_COMMON_H

=== modified file 'modules/heartbeat/hipd/heartbeat.c'
--- modules/heartbeat/hipd/heartbeat.c  2010-09-10 14:31:49 +0000
+++ modules/heartbeat/hipd/heartbeat.c  2010-11-09 16:37:54 +0000
@@ -1,7 +1,7 @@
 /**
  * @file
  *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'modules/heartbeat/hipd/heartbeat.h'
--- modules/heartbeat/hipd/heartbeat.h  2010-07-04 17:54:18 +0000
+++ modules/heartbeat/hipd/heartbeat.h  2010-09-25 18:30:26 +0000
@@ -1,7 +1,7 @@
 /**
  * @file
  *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'modules/heartbeat_update/hipd/hb_update.c'
--- modules/heartbeat_update/hipd/hb_update.c   2010-09-10 14:31:49 +0000
+++ modules/heartbeat_update/hipd/hb_update.c   2010-11-09 16:37:54 +0000
@@ -1,7 +1,7 @@
 /**
  * @file
  *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'modules/heartbeat_update/hipd/hb_update.h'
--- modules/heartbeat_update/hipd/hb_update.h   2010-07-04 17:54:18 +0000
+++ modules/heartbeat_update/hipd/hb_update.h   2010-09-25 18:30:26 +0000
@@ -1,7 +1,7 @@
 /**
  * @file
  *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'modules/update/hipd/update.c'
--- modules/update/hipd/update.c        2010-09-10 14:31:49 +0000
+++ modules/update/hipd/update.c        2010-11-09 16:37:54 +0000
@@ -3,7 +3,7 @@
  * This file defines various functions for sending, handling and receiving
  * UPDATE packets for the Host Identity Protocol (HIP)
  *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -384,6 +384,11 @@
     }
 }
 
+/**
+ * Print all IP addresses where an update packet should be sent to.
+ *
+ * @param ha    pointer to a host association
+ */
 static void hip_print_addresses_to_send_update_request(hip_ha_t *ha)
 {
     int i = 0;
@@ -1063,9 +1068,9 @@
 
    /* set local UDP port just in case the original communications
       changed from raw to UDP or vice versa */
-    ctx->hadb_entry->local_udp_port = ctx->msg_ports->dst_port;
+    ctx->hadb_entry->local_udp_port = ctx->msg_ports.dst_port;
     /* @todo: a workaround for bug id 592200 */
-    ctx->hadb_entry->peer_udp_port = ctx->msg_ports->src_port;
+    ctx->hadb_entry->peer_udp_port = ctx->msg_ports.src_port;
 
     /* RFC 5206: End-Host Mobility and Multihoming.
      * 3.2.1. Mobility with a Single SA Pair (No Rekeying)
@@ -1077,7 +1082,7 @@
     if (locator) {
         err = hip_handle_first_update_packet(ctx->input_msg,
                                              ctx->hadb_entry,
-                                             ctx->src_addr);
+                                             &ctx->src_addr);
         goto out_err;
     } else if (echo_request) {
         /* Ignore the ECHO REQUESTS with the same SEQ after processing the 
first
@@ -1091,13 +1096,13 @@
          */
         hip_handle_second_update_packet(ctx->input_msg,
                                         ctx->hadb_entry,
-                                        ctx->dst_addr,
-                                        ctx->src_addr);
+                                        &ctx->dst_addr,
+                                        &ctx->src_addr);
         goto out_err;
     } else if (echo_response) {
         hip_handle_third_update_packet(ctx->hadb_entry,
-                                       ctx->dst_addr,
-                                       ctx->src_addr);
+                                       &ctx->dst_addr,
+                                       &ctx->src_addr);
         goto out_err;
     }
     else if (esp_prot_update_type(ctx->input_msg)
@@ -1105,8 +1110,8 @@
     {
        esp_prot_handle_first_update_packet(ctx->input_msg,
                                            ctx->hadb_entry,
-                                           ctx->src_addr,
-                                           ctx->dst_addr);
+                                           &ctx->src_addr,
+                                           &ctx->dst_addr);
 
        goto out_err;
     }
@@ -1114,8 +1119,8 @@
                 == ESP_PROT_SECOND_UPDATE_PACKET)
    {
        esp_prot_handle_second_update_packet(ctx->hadb_entry,
-                                            ctx->src_addr,
-                                            ctx->dst_addr);
+                                            &ctx->src_addr,
+                                            &ctx->dst_addr);
 
        goto out_err;
    }

=== modified file 'modules/update/hipd/update.h'
--- modules/update/hipd/update.h        2010-09-10 14:26:44 +0000
+++ modules/update/hipd/update.h        2010-11-09 16:37:54 +0000
@@ -1,10 +1,5 @@
-/** @file
- * The header file for update.c
- *
- * @author  Baris Boyvat <baris#boyvat.com>
- * @version 0.1
- * @date    3.5.2009
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -28,6 +23,13 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
+/**
+ * @file
+ * @author  Baris Boyvat <baris#boyvat.com>
+ * @version 0.1
+ * @date    3.5.2009
+ */
+
 #ifndef HIP_HIPD_UPDATE_H
 #define HIP_HIPD_UPDATE_H
 

=== modified file 'modules/update/hipd/update_legacy.c'
--- modules/update/hipd/update_legacy.c 2010-07-29 13:41:29 +0000
+++ modules/update/hipd/update_legacy.c 2010-09-25 18:30:26 +0000
@@ -1,6 +1,6 @@
 /**
  * @file
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'modules/update/hipd/update_legacy.h'
--- modules/update/hipd/update_legacy.h 2010-07-07 16:22:48 +0000
+++ modules/update/hipd/update_legacy.h 2010-09-25 18:30:26 +0000
@@ -1,7 +1,7 @@
 /**
  * @file
  *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation

=== modified file 'modules/user_ipsec/hipd/user_ipsec_hipd_msg.c'
--- modules/user_ipsec/hipd/user_ipsec_hipd_msg.c       2010-09-03 11:40:19 
+0000
+++ modules/user_ipsec/hipd/user_ipsec_hipd_msg.c       2010-11-09 16:37:54 
+0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * Messaging required for the userspace IPsec implementation of the hipfw
  *
  * @brief userspace IPsec hipd <-> hipfw communication

=== modified file 'modules/user_ipsec/hipd/user_ipsec_hipd_msg.h'
--- modules/user_ipsec/hipd/user_ipsec_hipd_msg.h       2010-08-25 12:53:17 
+0000
+++ modules/user_ipsec/hipd/user_ipsec_hipd_msg.h       2010-11-09 16:37:54 
+0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * Messaging required for the userspace IPsec implementation of the hipfw
  *
  * @brief userspace IPsec hipd <-> hipfw communication

=== modified file 'modules/user_ipsec/hipd/user_ipsec_sadb_api.c'
--- modules/user_ipsec/hipd/user_ipsec_sadb_api.c       2010-09-10 14:33:51 
+0000
+++ modules/user_ipsec/hipd/user_ipsec_sadb_api.c       2010-11-09 16:37:54 
+0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,14 +21,16 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * Provides the API used by the hipd to set up and maintain the
  * userspace IPsec state in the hipfw.
  *
  * @brief API used by the hipd to set up and maintain userspace IPsec state
  *
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #include <stdint.h>

=== modified file 'modules/user_ipsec/hipd/user_ipsec_sadb_api.h'
--- modules/user_ipsec/hipd/user_ipsec_sadb_api.h       2010-09-10 14:26:44 
+0000
+++ modules/user_ipsec/hipd/user_ipsec_sadb_api.h       2010-11-09 16:37:54 
+0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,14 +21,16 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * Provides the API used by the hipd to set up and maintain the
  * userspace IPsec state in the hipfw.
  *
  * @brief API used by the hipd to set up and maintain userspace IPsec state
  *
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
- *
  */
 
 #ifndef HIP_HIPD_USER_IPSEC_SADB_API_H

=== modified file 'packaging/create-package.sh'
--- packaging/create-package.sh 2010-06-30 11:24:04 +0000
+++ packaging/create-package.sh 2010-10-29 10:52:36 +0000
@@ -1,33 +1,6 @@
 #!/bin/sh
 
-VERSION=$(grep '^AC_INIT' configure.ac|cut -d'[' -f 3|cut -d']' -f1)
-RELEASE=
-NAME=hipl
-PKGROOT=$PWD
-PKGEXE=$PKGROOT/packaging
-PKG_WEB_DIR=
-PKG_SERVER_DIR=
-DEBDIR=$PWD/debbuild
-RPMDIR=$PWD/rpmbuild
-RPMBUILD=/tmp/rpmbuild
-SUBDEBDIRS="BUILD DEBS SOURCES SPECS SDEBS"
-SUBRPMDIRS="BUILD RPMS SOURCES SPECS SRPMS"
-SUDO= # no sudo
-ARCH=
-DISTRO_RELEASE=
-DISTRO=
-DISTROBASE=
-DISTRO_PKG_SUFFIX=
-REPO_SERVER=hipl.hiit.fi
-REPO_BASE=/var/www/packages/html
-BIN_FORMAT=
-TARBALL=
-RSYNC_OPTS=-uvr
-REPO_USER=hipl
-REPO_GROUP=hipl
-SPECFILE_DIR=$(mktemp -d)
-SPECFILE=$SPECFILE_DIR/hipl.spec
-OPT_CHANGELOG='doc/ChangeLog'
+############### helper functions #####################
 
 die()
 {
@@ -35,182 +8,128 @@
     exit 1
 }
 
-set_release_version()
-{
-    if test -r $OPT_CHANGELOG; then
-        RELEASE=$(head -2 $OPT_CHANGELOG | tail -1 | cut -d" " -f2)
-    else
-        RELEASE=$(bzr log --line -l 1 | cut -d: -f1)
-    fi
-}
-
-build_rpm()
-{
-    echo "Deleting old .rpmmacros"
-    echo "%_topdir $RPMBUILD" > $HOME/.rpmmacros
-
-    for SUBDIR in $SUBRPMDIRS; do
-        if test ! -d $RPMBUILD/$SUBDIR; then
-            $SUDO mkdir -p $RPMBUILD/$SUBDIR
-        fi
-    done
-
-    # fix this hack -miika
-    test -d $RPMBUILD/RPMS/i586 &&
-        cp -a $RPMBUILD/RPMS/i586 $RPMBUILD/RPMS/i386
-
-    $SUDO mv -f $TARBALL $RPMBUILD/SOURCES
-    $SUDO rpmbuild -ba $SPECFILE
-
-    # rpmbuild does not want to build to $RPMDIR, so let's just move it
-    # to there from $RPMBUILD
-    test -d $RPMDIR && rm -rf $RPMDIR
-    mv $RPMBUILD $RPMDIR
-    find $RPMDIR -name '*rpm'
-}
-
 mkindex_rpm()
 {
-    test ! -d $PKG_INDEX && mkdir $PKG_INDEX
-    # fix this hack -miika
-    test -d  /tmp/hipl-${VERSION}/buildenv/RPMS/i586 &&
-        cp -a /tmp/hipl-${VERSION}/buildenv/RPMS/i586 
/tmp/hipl-${VERSION}/buildenv/RPMS/i386
-    #$SUDO createrepo --update --outputdir=$PKG_INDEX_DIR $PKG_DIR
-    $SUDO createrepo --outputdir=$PKG_INDEX_DIR $PKG_DIR
+    mkdir -p $PKG_DIR
+    createrepo $PKG_DIR
 }
 
 mkindex_deb()
 {
-    ORIG=$PWD
-    cd $PKG_DIR
-    WD=$(echo $PKG_WEB_DIR | sed 's/ubuntu\///' | sed 's/\//\\\//g')
-    #dpkg-scanpackages --multiversion . |
-    dpkg-scanpackages . | \
-        sed "s/Filename: \./Filename: $WD/" | \
+    PKG_WEB_DIR=dists/$DISTRO_RELEASE/main/binary-${ARCH}
+
+    dpkg-scanpackages $PKG_DIR |
+        sed "s,Filename: $PKG_DIR,Filename: $PKG_WEB_DIR," |
         gzip -9c > $PKG_INDEX
-    cd $ORIG
 }
 
 syncrepo()
 {
+    $INDEXING_CMD
+
+    NAME=hipl
+    REPO_SERVER=hipl.hiit.fi
+    REPO_USER=hipl
+
     # create repo dir if it does not exist
     ssh ${REPO_USER}@${REPO_SERVER} mkdir -p $PKG_SERVER_DIR
 
-    # build index of all packages
-    if test x"$DISTROBASE" = x"debian"; then
-        mkindex_deb
-    elif test x"$DISTROBASE" = x"redhat"; then
-        mkindex_rpm
-    else
-        die "Unhandled distro $DISTROBASE"
-    fi
-
     # Delete old packages from the repo
     ssh  ${REPO_USER}@${REPO_SERVER} "rm -f 
${PKG_SERVER_DIR}/*.${DISTRO_PKG_SUFFIX}"
 
     # Copy all packages and repo index to the repository
-    rsync $RSYNC_OPTS $PKG_DIR/${NAME}-*${VERSION}*.${DISTRO_PKG_SUFFIX} 
${PKG_INDEX} ${REPO_USER}@${REPO_SERVER}:${PKG_SERVER_DIR}/
-
+    rsync -uvr $PKG_DIR/${NAME}-*${VERSION}*.${DISTRO_PKG_SUFFIX} ${PKG_INDEX} 
${REPO_USER}@${REPO_SERVER}:${PKG_SERVER_DIR}/
+}
+
+build_package()
+{
+    rm -rf $BUILDDIR
+    for SUBDIR in $SUBBUILDDIRS; do
+        mkdir -p $BUILDDIR/$SUBDIR
+    done
+
+    RELEASE=$(grep BZR_REVISION $SRCDIR/version.h | cut -d\" -f2)
+
+    echo "Version: $VERSION"  > $SPECFILE
+    echo "Release: $RELEASE" >> $SPECFILE
+    echo "%define _topdir $BUILDDIR" >> $SPECFILE
+    cat $SPECFILE_TEMPLATE   >> $SPECFILE
+
+    make dist > /dev/null
+    mv -f hipl-${VERSION}.tar.gz $BUILDDIR/SOURCES
+
+    $PACKAGING_CMD
+}
+
+build_rpm()
+{
+    rpmbuild --target $ARCH -ba $SPECFILE
 }
 
 build_deb()
 {
-    test -e ~/.debmacros && echo "Warning: ~/.debmacros found, could be a 
problem"
-    if test -e ~/debbuild; then
-        echo "Warning: ~/debbuild found, could be a problem"
-        echo "It should be a link to /usr/src/debian"
-    fi
-
-    if test ! -x /usr/bin/pax; then
-        die "apt-get install pax"
-    fi
-
-    for SUBDIR in $SUBDEBDIRS; do
-        if test ! -d $DEBDIR/$SUBDIR; then
-            mkdir -p $DEBDIR/$SUBDIR
-        fi
-    done
-
-    cp $SPECFILE $DEBDIR/SPECS
-
-    mv -f $TARBALL $DEBDIR/SOURCES
     # http://www.deepnet.cx/debbuild/
-    $PKGEXE/debbuild --buildroot $DEBDIR -ba $SPECFILE
+    $SRCDIR_PACKAGING/debbuild --buildroot $BUILDDIR -ba $SPECFILE
 }
 
 ############### Main program #####################
 
 set -e
 
-set_release_version
-echo "Version: $VERSION" > $SPECFILE
-echo "Release: $RELEASE" >> $SPECFILE
+SRCDIR=$(echo $0 | sed s:/packaging/create-package.sh::)
+VERSION=$(grep '^AC_INIT' $SRCDIR/configure.ac | cut -d'[' -f 3 | cut -d']' 
-f1)
+SRCDIR_PACKAGING=$SRCDIR/packaging
+REPO_BASE=/var/www/packages/html
 
 # Set architecture, distro and repo details
 if test -r /etc/debian_version; then
-    DISTROBASE=debian
+    which pax > /dev/null || die "aptitude install pax"
+    DISTRO=debian
+    DISTRO_RELEASE=$(lsb_release -c | cut -f2)
     ARCH=$(dpkg --print-architecture)
-    PKG_DIR=$DEBDIR/DEBS/$ARCH
-    DISTRO_RELEASE=$(lsb_release -c | cut -f2)
-    PKG_WEB_DIR=ubuntu/dists/$DISTRO_RELEASE/main/binary-${ARCH}
-    PKG_SERVER_DIR=$REPO_BASE/$DISTRO/$PKG_WEB_DIR
-    cat $PKGEXE/hipl-deb.spec >> $SPECFILE
+    BUILDDIR=$PWD/debbuild
+    SUBBUILDDIRS="BUILD SOURCES SPECS DEBS SDEBS"
+    PKG_DIR=$BUILDDIR/DEBS/$ARCH
+    PKG_SERVER_DIR=$REPO_BASE/ubuntu/dists/$DISTRO_RELEASE/main/binary-${ARCH}
+    SPECFILE_TEMPLATE=$SRCDIR_PACKAGING/hipl-deb.spec
     DISTRO_PKG_SUFFIX=deb
     PKG_INDEX_NAME=Packages.gz
+    INDEXING_CMD=mkindex_deb
+    PACKAGING_CMD=build_deb
 elif test -r /etc/redhat-release; then
-    DISTROBASE=redhat
+    DISTRO=redhat
+    DISTRO_RELEASE=$(lsb_release -r | cut -f2)
     ARCH=$(uname -i)
-    PKG_DIR=$RPMDIR/RPMS/$ARCH
-    DISTRO_RELEASE=$(lsb_release -r | cut -f2)
-    PKG_WEB_DIR=fedora/base/$DISTRO_RELEASE/$ARCH
-    PKG_SERVER_DIR=$REPO_BASE/$PKG_WEB_DIR
-    cat $PKGEXE/hipl-rpm.spec >> $SPECFILE
+    BUILDDIR=$PWD/rpmbuild
+    SUBBUILDDIRS="BUILD SOURCES SPECS RPMS SRPMS"
+    PKG_DIR=$BUILDDIR/RPMS/$ARCH
+    PKG_SERVER_DIR=$REPO_BASE/fedora/base/$DISTRO_RELEASE/$ARCH
+    SPECFILE_TEMPLATE=$SRCDIR_PACKAGING/hipl-rpm.spec
     DISTRO_PKG_SUFFIX=rpm
     PKG_INDEX_NAME=repodata
+    INDEXING_CMD=mkindex_rpm
+    PACKAGING_CMD=build_rpm
 else
-    die "Unknown architecture"
+    die "unknown distribution"
 fi
 
-DISTRO=$(lsb_release -d | cut -f2 | tr '[:upper:]' '[:lower:]' | cut -d" " -f1)
-PKG_INDEX_DIR=$PKGEXE
-PKG_INDEX=$PKG_INDEX_DIR/$PKG_INDEX_NAME
-
-TARBALL=$PKGROOT/hipl-${VERSION}.tar.gz
+PKG_INDEX=$PKG_DIR/$PKG_INDEX_NAME
+SPECFILE=$BUILDDIR/SPECS/hipl.spec
 
 # Determine action
-if test x"$1" = x"syncrepo"; then
-    syncrepo
-    exit
-elif test x"$1" = x"bin"; then
-    if test x"$DISTROBASE" = x"redhat"; then
-        BIN_FORMAT=rpm
-    elif test x"$DISTROBASE" = x"debian"; then
-        BIN_FORMAT=deb
-    else
-        die "Unknown distro"
-    fi
-fi
-echo "Architecture: $ARCH"
-
-echo <<EOF
-** Creating the directory structure and files for building the
-** source package needed for RPM package containing HIPL
-** user space software
-**
-** Version $VERSION
-**
-EOF
-
-make dist
-ls -ld $TARBALL
-
-echo "*** Cleaning up ${DEBDIR} ***"
-rm -rf ${DEBDIR}
-
-if test x"$1" = x"rpm" || test x"$BIN_FORMAT" = x"rpm"; then
-    build_rpm
-elif test x"$1" = x"deb" || test x"$BIN_FORMAT" = x"deb"; then
-    build_deb
-else
-    die "*** Unknown platform, aborting ***"
-fi
+case $1 in
+    syncrepo_deb)
+        INDEXING_CMD=mkindex_deb syncrepo ;;
+    syncrepo_rpm)
+        INDEXING_CMD=mkindex_rpm syncrepo ;;
+    syncrepo)
+        syncrepo ;;
+    deb)
+        PACKAGING_CMD=build_deb build_package ;;
+    rpm)
+        PACKAGING_CMD=build_rpm build_package ;;
+    bin)
+        build_package ;;
+    *)
+        die "usage: $0 <syncrepo|syncrepo_deb|syncrepo_rpm|deb|rpm|bin>"
+esac

=== modified file 'packaging/debbuild'
--- packaging/debbuild  2010-02-24 13:01:02 +0000
+++ packaging/debbuild  2010-10-22 16:33:12 +0000
@@ -69,9 +69,9 @@
 # Initialized globals
 my $verbosity = 0;
 my $NoAutoReq = 0;
-my %cmdopts = (type => '',
-                stage => 'a',
-                short => 'n'
+my %cmdopts = (type  => '',
+               stage => 'a',
+               short => 'n'
         );
 my $topdir = "/usr/src/debian";
 #my $specglobals{buildroot} = 
"%{_tmppath}/%{name}-%{version}-%{release}.root".int(rand(99998)+1);
@@ -79,12 +79,12 @@
 
 # "Constants"
 my %targets = ('p' => 'Prep',
-                'c' => 'Compile',
-                'i' => 'Install',
-                'l' => 'Verify %files',
-                'a' => 'Build binary and source',
-                'b' => 'Build binary',
-                's' => 'Build source'
+               'c' => 'Compile',
+               'i' => 'Install',
+               'l' => 'Verify %files',
+               'a' => 'Build binary and source',
+               'b' => 'Build binary',
+               's' => 'Build source'
         );
 # Ah, the joys of multiple architectures.  :(  Feh.
 # As copied from rpm
@@ -98,8 +98,8 @@
 # than one Debian version at the same time.  Whee.
 # /etc/debian-version
 my %distmap = (
-        "3.1.9ubuntu7.1"        => "dapper",
-        "4ubuntu2"      => "feisty",
+        "3.1.9ubuntu7.1" => "dapper",
+        "4ubuntu2"       => "feisty",
         "3.0"   => "woody",
         "3.1"   => "sarge",
         "4"     => "etch",
@@ -180,7 +180,6 @@
 }
 $scriptletbase .=
 q(
-  set -x
   umask 022
   cd %{_topdir}/BUILD
 );
@@ -704,7 +703,7 @@
         $prepscript .= "tar -".
                 ( $pkgdata{main}{source} =~ /\.tar\.gz$/ ? "z" : "" ).
                 ( $pkgdata{main}{source} =~ /\.tar\.bz2$/ ? "j" : "" ).
-                ( /\s+-q\s+/ ? '' : 'vv' )."xf ".
+                "xf ".
                 "$topdir/SOURCES/$pkgdata{main}{source}\n".
                 qq(STATUS=\$?\nif [ \$STATUS -ne 0 ]; then\n  exit 
\$STATUS\nfi\n).
                 "cd $topdir/BUILD/$tarballdir\n".

=== modified file 'packaging/hipl-deb.spec'
--- packaging/hipl-deb.spec     2010-07-04 17:54:18 +0000
+++ packaging/hipl-deb.spec     2010-11-05 14:17:19 +0000
@@ -4,7 +4,7 @@
 #       by packaging/create-package.sh
 # Note: To check that this file is in correct format, type
 # ./debbuild --showpkgs hipl-deb.spec
-URL: http://infrahip.hiit.fi
+URL: http://infrahip.hiit.fi/
 Source: 
http://infrahip.hiit.fi/hipl/release/sources/%{version}/hipl-%{version}.tar.gz
 Packager: miika@xxxxxx
 Vendor: InfraHIP
@@ -14,6 +14,7 @@
 ExclusiveOS: linux
 BuildRoot: %{_tmppath}/%{name}-%{version}-root
 Prefix: /usr
+
 %description
 
 Host Identity Protocol (HIP) provides cryptographic authentication to
@@ -29,8 +30,8 @@
 # Note: in subsequent releases me may want to use --disable-debugging
 %build
 autoreconf --install
-%configure --prefix=/usr
-make -j 4 all
+%configure --prefix=/usr --sysconfdir=/etc
+make -j
 
 # Note:
 # This debbuild script is fragile and does not tolerate comments well.
@@ -69,7 +70,7 @@
 
 
 %package all
-Summary: HIPL software bundle: HIP for Linux libraries, daemons and 
documentation
+Summary: Full HIPL software bundle. This virtual package is suitable e.g. for 
client machines.
 Group: System Environment/Kernel
 Requires: hipl-lib, hipl-firewall, hipl-daemon, hipl-tools, hipl-doc, 
hipl-dnsproxy
 %description all
@@ -118,18 +119,11 @@
 %install
 rm -rf %{buildroot}
 
-install -d %{buildroot}/usr/share/pixmaps
-install -d %{buildroot}/usr/bin
-install -d %{buildroot}/usr/sbin
-install -d %{buildroot}/usr/lib
+make install-strip DESTDIR=%{buildroot}
 install -d %{buildroot}/etc/init.d
-install -d %{buildroot}/doc
-make DESTDIR=%{buildroot} install
 install -m 755 packaging/debian-init.d/hipfw %{buildroot}/etc/init.d/hipfw
 install -m 755 packaging/debian-init.d/hipd %{buildroot}/etc/init.d/hipd
 install -m 755 packaging/debian-init.d/dnsproxy 
%{buildroot}/etc/init.d/hipdnsproxy
-install -m 644 doc/HOWTO.txt %{buildroot}/doc
-install -m 644 doc/HOWTO.html %{buildroot}/doc
 install -d %{buildroot}/usr/lib/python2.6/dist-packages/DNS
 install -t %{buildroot}/usr/lib/python2.6/dist-packages/DNS 
tools/hipdnsproxy/DNS/*py*
 install -t %{buildroot}/usr/lib/python2.6/dist-packages 
tools/hipdnsproxy/pyip6.py*
@@ -137,8 +131,6 @@
 install -t %{buildroot}/usr/lib/python2.6/dist-packages 
tools/hipdnsproxy/util.py*
 install -t %{buildroot}/usr/lib/python2.6/dist-packages 
tools/hipdnskeyparse/myasn.py*
 install -t %{buildroot}/usr/lib/python2.6/dist-packages/hipdnsproxy 
tools/hipdnsproxy/hipdnsproxy
-install -m 755 tools/hipdnskeyparse/hipdnskeyparse 
%{buildroot}/usr/sbin/hipdnskeyparse
-install -m 755 tools/hipdnsproxy/hipdnsproxy %{buildroot}/usr/sbin/hipdnsproxy
 
 %post lib
 /sbin/ldconfig
@@ -199,6 +191,8 @@
 
 %files doc
 %doc doc/HOWTO.txt doc/HOWTO.html
+%doc doc/base-exchange-relay.png doc/base-exchange-rvs.png
+%doc doc/docshot-agent-main-window.png doc/docshot-agent-tray-icon.png
 
 %files all
 %doc COPYING

=== modified file 'packaging/hipl-rpm.spec'
--- packaging/hipl-rpm.spec     2010-07-04 17:54:18 +0000
+++ packaging/hipl-rpm.spec     2010-11-05 14:17:19 +0000
@@ -26,10 +26,15 @@
 %setup
 
 # Note: in subsequent releases me may want to use --disable-debugging
+# Note: CentOS 5.5 requires special cpp flags (see bug id #620327)
 %build
 autoreconf --install
-%configure --prefix=/usr
-make -j 4 all
+%if 0%{?fedora}
+%configure --prefix=/usr --sysconfdir=/etc
+%else
+CPPFLAGS=-U__STRICT_ANSI__ ./configure --prefix=/usr --sysconfdir=/etc
+%endif
+make -j
 
 # Currently we are not going to install all includes and test software.
 # As a consequence, we need to tell rpmbuild that we don't want to package
@@ -106,17 +111,11 @@
 
 # XX FIXME: add more python stuff from tools directory
 
-install -d %{buildroot}%{prefix}/bin
-install -d %{buildroot}%{prefix}/sbin
-install -d %{buildroot}%{prefix}/lib
+make install-strip DESTDIR=%{buildroot}
 install -d %{buildroot}/etc/rc.d/init.d
-install -d %{buildroot}/doc
-make DESTDIR=%{buildroot} install
 install -m 755 packaging/fedora-init.d/hipfw %{buildroot}/etc/rc.d/init.d/hipfw
 install -m 755 packaging/fedora-init.d/hipd %{buildroot}/etc/rc.d/init.d/hipd
 install -m 755 packaging/fedora-init.d/dnsproxy 
%{buildroot}/etc/rc.d/init.d/hipdnsproxy
-install -m 644 doc/HOWTO.txt %{buildroot}/doc
-install -m 644 doc/HOWTO.html %{buildroot}/doc
 install -d %{buildroot}%{python_sitelib}/DNS
 install -t %{buildroot}%{python_sitelib}/DNS tools/hipdnsproxy/DNS/*py*
 install -d %{buildroot}%{python_sitelib}/hipdnskeyparse
@@ -125,9 +124,6 @@
 install -t %{buildroot}%{python_sitelib} tools/hipdnsproxy/hosts.py*
 install -t %{buildroot}%{python_sitelib} tools/hipdnsproxy/util.py*
 install -t %{buildroot}%{python_sitelib} tools/hipdnskeyparse/myasn.py* # XX 
FIXME
-# required in CentOS release 5.2
-install -m 755 tools/hipdnskeyparse/hipdnskeyparse 
%{buildroot}%{prefix}/sbin/hipdnskeyparse
-install -m 755 tools/hipdnsproxy/hipdnsproxy 
%{buildroot}%{prefix}/sbin/hipdnsproxy
 
 %post lib
 /sbin/ldconfig
@@ -224,6 +220,8 @@
 
 %files doc
 %doc doc/HOWTO.txt doc/HOWTO.html
+%doc doc/base-exchange-relay.png doc/base-exchange-rvs.png
+%doc doc/docshot-agent-main-window.png doc/docshot-agent-tray-icon.png
 
 %files all
 

=== modified file 'packaging/openwrt/package/Makefile'
--- packaging/openwrt/package/Makefile  2010-05-20 16:14:34 +0000
+++ packaging/openwrt/package/Makefile  2010-10-29 11:31:40 +0000
@@ -1,15 +1,14 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=hipl
-PKG_BRANCHNAME:=main
 PKG_VERSION:=1.0.6
 PKG_RELEASE:=6
 
-PKG_SOURCE:=$(PKG_NAME)-$(PKG_BRANCHNAME).tar.gz
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=http://hipl.hiit.fi/hipl/contrib/openwrt/
 PKG_CAT:=zcat
 
-PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_BRANCHNAME)
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
 PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
 
 include $(INCLUDE_DIR)/package.mk
@@ -18,7 +17,7 @@
     SECTION:=net
     CATEGORY:=Network
     DEPENDS:=+hipl-common +genl +ip +kmod-ipsec +kmod-ipsec4 +kmod-ipsec6 
+kmod-loop +kmod-nbd +kmod-tun +libpthread +losetup +kmod-dummy +kmod-ipip 
+kmod-crypto-authenc +kmod-ip6-tunnel
-    TITLE:=HIPL deamon
+    TITLE:=HIPL daemon
     URL:=http://hipl.hiit.fi/
 endef
 
@@ -40,30 +39,6 @@
  The firewall for HIPL.
 endef
 
-define Package/hipl-hipconf
-    SECTION:=net
-    CATEGORY:=Network
-    DEPENDS:=+hipl-hipd
-    TITLE:=HIPL configuration application
-    URL:=http://hipl.hiit.fi/
-endef
-
-define Package/hipl-hipconf/description
- The configuration application for the hipd of the HIPL implementation.
-endef
-
-define Package/hipl-hipproxy
-    SECTION:=net
-    CATEGORY:=Network
-    DEPENDS:=+hipl-hipd +hipl-hipfw
-    TITLE:=HIPL proxy
-    URL:=http://hipl.hiit.fi/
-endef
-
-define Package/hipl-hipproxy/description
- The scripts for running the hipproxy.
-endef
-
 define Package/hipl-common
     SECTION:=net
     CATEGORY:=Network
@@ -86,6 +61,7 @@
 
 define Build/Configure
        $(call Build/Configure/Default, \
+            --sysconfdir=/etc \
             --enable-shared \
             --disable-debug \
     );
@@ -102,6 +78,8 @@
 
        $(INSTALL_BIN) ./files/hipd.init $(1)/etc/init.d/hipd
        $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/hipd $(1)/usr/sbin/
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/hipconf $(1)/usr/sbin/
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/hipdnsproxy $(1)/usr/sbin/
 endef
 
 define Package/hipl-hipfw/install
@@ -112,41 +90,19 @@
        $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/hipfw $(1)/usr/sbin/
 endef
 
-define Package/hipl-hipconf/install
-       $(INSTALL_DIR) $(1)/usr/sbin/
-
-       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/hipconf $(1)/usr/sbin/
-endef
-
-define Package/hipl-hipproxy/install
-       $(INSTALL_DIR) $(1)/usr/sbin/
-
-       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/hipdnsproxy $(1)/usr/sbin/
-endef
-
 define Package/hipl-common/install
        $(INSTALL_DIR) $(1)/etc/hip/
        $(INSTALL_DIR) $(1)/etc/modules.d/
        $(INSTALL_DIR) $(1)/usr/lib/
-       $(INSTALL_DIR) $(1)/usr/bin/
-       $(INSTALL_DIR) $(1)/usr/include/
-       $(INSTALL_DIR) $(1)/usr/include/libipsec
 
        $(INSTALL_DATA) ./files/hipl.modules $(1)/etc/modules.d/35-hipl
        $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libhipcore.so* $(1)/usr/lib/
-       $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libhipcore.la $(1)/usr/lib/
        $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libmod.so* $(1)/usr/lib/
-       $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libmod.la $(1)/usr/lib/
        $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libhipheartbeat.so* 
$(1)/usr/lib/
-       $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libhipheartbeat.la 
$(1)/usr/lib/
        $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libhiphbupdate.so* 
$(1)/usr/lib/
-       $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libhiphbupdate.la 
$(1)/usr/lib/
        $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libhipupdate.so* 
$(1)/usr/lib/
-       $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libhipupdate.la $(1)/usr/lib/
 endef
 
 $(eval $(call BuildPackage,hipl-common))
 $(eval $(call BuildPackage,hipl-hipd))
 $(eval $(call BuildPackage,hipl-hipfw))
-$(eval $(call BuildPackage,hipl-hipconf))
-$(eval $(call BuildPackage,hipl-hipproxy))

=== modified file 'test/auth_performance.c'
--- test/auth_performance.c     2010-07-04 17:54:18 +0000
+++ test/auth_performance.c     2010-10-18 17:06:20 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -23,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * This file contains a benchmark for the cryptographic authentication 
functions.
  *
  * @brief Authentication function benchmark
@@ -62,14 +63,12 @@
 int dsa_key_len      = 1024;
 #define ECDSA_CURVE NID_sect163r1
 
-/*!
- * \brief Determine and print the gettimeofday time resolution.
- *
- * \author Tobias Heer
+/**
+ * @brief Determine and print the gettimeofday time resolution.
  *
  * Determine the time resolution of gettimeofday.
  *
- * \return void
+ * @return void
  */
 static void print_timeres(void)
 {

=== modified file 'test/certteststub.c'
--- test/certteststub.c 2010-07-16 17:19:52 +0000
+++ test/certteststub.c 2010-10-15 15:29:14 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -24,7 +22,9 @@
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
  */
-/** @file
+
+/**
+ * @file
  * A teststub for certtools.c/h
  *
  * File for testing the main operations of certtools.
@@ -33,7 +33,6 @@
  * Then it tries to verify it. If it succeeds everything should be OK :)
  *
  * @author Samu Varjonen
- *
  */
 
 #include <stdio.h>

=== added file 'test/check_lib_core.c'
--- test/check_lib_core.c       1970-01-01 00:00:00 +0000
+++ test/check_lib_core.c       2010-10-29 11:30:05 +0000
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file
+ * @brief Unit tests of lib/core (see doc/HACKING on unit tests).
+ * @author Stefan Goetz <stefan.goetz@xxxxxxxxxxxxxxxxx>
+ */
+#include <stdlib.h>
+#include <check.h>
+
+// Import test suite functions from their respective C files via forward
+// declarations.
+// Since each test C file exports only one such function which is only used
+// right here, a dedicated header file for each of them adds unnecessary file
+// clutter in this particular case of unit tests.
+// Do not adopt this HFAS (header-file-avoidance-scheme) (TM) in HIPL 
production
+// code as header files are generally a good idea, just not here.
+extern Suite *lib_core_hit (void);
+extern Suite *lib_core_straddr (void);
+
+int main(void)
+{
+    int number_failed;
+    SRunner *sr = srunner_create(lib_core_hit());
+    srunner_add_suite(sr, lib_core_straddr());
+
+    srunner_run_all(sr, CK_NORMAL);
+    number_failed = srunner_ntests_failed(sr);
+    srunner_free(sr);
+    return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+

=== modified file 'test/dh_performance.c'
--- test/dh_performance.c       2010-07-07 16:03:48 +0000
+++ test/dh_performance.c       2010-10-18 17:06:20 +0000
@@ -1,14 +1,5 @@
-/*!
- * \file dh_performance.c
- *
- * \brief Performance testfile that can be used for benchmarking a system.
- * \author Tobias Heer
- *
- * This is file provides an executable that can be run to benchmark a HIP 
system.
- * It provides detailed information about the runtime of certain cryptographic
- * operations.
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -30,7 +21,17 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
+ *
+ * @brief Performance testfile that can be used for benchmarking a system.
+ * @author Tobias Heer
+ *
+ * This is file provides an executable that can be run to benchmark a HIP 
system.
+ * It provides detailed information about the runtime of certain cryptographic
+ * operations.
  */
 
 #include <stdint.h>
@@ -53,7 +54,7 @@
 #include "lib/tool/pk.h"
 
 
-/*! \brief Number of benchmark runs */
+/** @brief Number of benchmark runs */
 #define DHP_DEFAULT_LOOPS 100
 
 
@@ -65,41 +66,39 @@
  */
 
 #define PS_DH_CREATE  0
-/** \brief Perf set number: Shared secret creation */
+/** @brief Perf set number: Shared secret creation */
 #define PS_DH_SHARE   1
-/*! \brief Perf set number: DSA key creation */
+/** @brief Perf set number: DSA key creation */
 #define PS_DSA_CREATE 2
-/*! \brief Perf set number: DSA signature creation */
+/** @brief Perf set number: DSA signature creation */
 #define PS_DSA_SIGN   3
-/*! \brief Perf set number: DSA verification */
+/** @brief Perf set number: DSA verification */
 #define PS_DSA_VERIFY 4
-/*! \brief Perf set number: DSA key creation */
+/** @brief Perf set number: DSA key creation */
 #define PS_RSA_CREATE 5
-/*! \brief Perf set number: RSA signature creation */
+/** @brief Perf set number: RSA signature creation */
 #define PS_RSA_SIGN   6
-/*! \brief Perf set number: RSA verification */
+/** @brief Perf set number: RSA verification */
 #define PS_RSA_VERIFY 7
-/*! \brief Perf set number: Hash chain creation */
+/** @brief Perf set number: Hash chain creation */
 #define PS_HC_CREATE  8
-/*! \brief Perf set number: Hash computation */
+/** @brief Perf set number: Hash computation */
 #define PS_HASH       9
-/* \brief Maximum perf set number. Number of file outputs */
+/* @brief Maximum perf set number. Number of file outputs */
 #define PS_MAX       10
-/*!@}*/
+/**@}*/
 
-/*! \brief Input bytes for the hash function */
+/** @brief Input bytes for the hash function */
 #define HASH_LEN     20
 
 
-/*!
- * \brief Print command line options.
+/**
+ * @brief Print command line options.
  *
  * Prints all possible command line options.
  *
- * \author Tobias Heer
- *
- * \param progname The name of the executable
- * \return void
+ * @param progname The name of the executable
+ * @return void
  */
 static void dhp_usage(char *progname)
 {
@@ -120,33 +119,31 @@
             , progname, DSA_KEY_DEFAULT_BITS);
 }
 
-/*!
- * \brief Get the option values from the input parameters.
+/**
+ * @brief Get the option values from the input parameters.
  *
  * Takes the input parameters, parses them and returns the option switches.
  *
- * \author Tobias Heer
- *
- * \param argv The arguments array.
- * \param argc The length of the arguments array.
- * \param sw_create_dh How many DH keys should be used?
- * \param sw_dh_group_id Which DH group ID (key type) should be used?
- * \param sw_create_dsa How many DSA keys should be used?
- * \param sw_create_rsa How many RSA keys should be used?
- * \param sw_rsa_keylen RSA key length.
- * \param sw_dsa_keylen DSA key length.
- * \param sw_bench_loops Repetitions for the public-key measurements.
- * \param sw_print_keys  Print the DH, RSA, and DSA keys (for debug).
- * \param sw_shared_key_len Length of the shared keys.
- * \param sw_hash_chain_len Length of the hash chain (elements)
- * \param sw_file_output Print data to files or to stdout
- * \param sw_cpuload Don't measure, only load the CPU.
- * \param sw_hash_loops Number of hash computations.
- *
- * \note all sw_ paramters are pointers to ouput parameters that are modified
+ * @param argv The arguments array.
+ * @param argc The length of the arguments array.
+ * @param sw_create_dh How many DH keys should be used?
+ * @param sw_dh_group_id Which DH group ID (key type) should be used?
+ * @param sw_create_dsa How many DSA keys should be used?
+ * @param sw_create_rsa How many RSA keys should be used?
+ * @param sw_rsa_keylen RSA key length.
+ * @param sw_dsa_keylen DSA key length.
+ * @param sw_bench_loops Repetitions for the public-key measurements.
+ * @param sw_print_keys  Print the DH, RSA, and DSA keys (for debug).
+ * @param sw_shared_key_len Length of the shared keys.
+ * @param sw_hash_chain_len Length of the hash chain (elements)
+ * @param sw_file_output Print data to files or to stdout
+ * @param sw_cpuload Don't measure, only load the CPU.
+ * @param sw_hash_loops Number of hash computations.
+ *
+ * @note all sw_ paramters are pointers to ouput parameters that are modified
  *       by dhp_getopts.
  *
- * \return Returns error code. 0 = Success, 1 = Error.
+ * @return Returns error code. 0 = Success, 1 = Error.
  */
 static int dhp_getopts(int argc,
                        char **argv,
@@ -268,14 +265,12 @@
     return 1;
 }
 
-/*!
- * \brief Determine and print the gettimeofday time resolution.
- *
- * \author Tobias Heer
+/**
+ * @brief Determine and print the gettimeofday time resolution.
  *
  * Determine the time resolution of gettimeofday.
  *
- * \return void
+ * @return void
  */
 static void print_timeres(void)
 {
@@ -298,30 +293,26 @@
     printf( "-------------------------------\n\n\n");
 }
 
-/*!
- * \brief Take time for benchmark.
+/**
+ * @brief Take time for benchmark.
  *
  * Starts a time interval.
  *
- * \author Tobias Heer
- *
- * \param bench_time timeval struct from the OS.
- * \return void
+ * @param bench_time timeval struct from the OS.
+ * @return void
  */
 static void dhp_start_benchmark(struct timeval *bench_time)
 {
     gettimeofday(bench_time, NULL);
 }
 
-/*!
- * \brief Take time for benchmark and return passed time.
+/**
+ * @brief Take time for benchmark and return passed time.
  *
  * Concludes a time interval and returns the past time.
  *
- * \author Tobias Heer
- *
- * \param bench_time timeval struct from the OS.
- * \return passed time since beginning of the interval.
+ * @param bench_time timeval struct from the OS.
+ * @return passed time since beginning of the interval.
  */
 static double dhp_stop_benchmark(struct timeval *bench_time)
 {
@@ -331,15 +322,13 @@
             * 1000000 + (now.tv_usec - bench_time->tv_usec)) / 1000000.0;
 }
 
-/*!
- * \brief Main function that performs the measurements.
- *
- * \author Tobias Heer
- *
- * \param argc Number of command line arguments
- * \param argv Command line argument array
- *
- * \return Returns error code. 0 = Success, 1 = Error.
+/**
+ * @brief Main function that performs the measurements.
+ *
+ * @param argc Number of command line arguments
+ * @param argv Command line argument array
+ *
+ * @return Returns error code. 0 = Success, 1 = Error.
  */
 int main(int argc, char **argv)
 {

=== modified file 'test/hc_performance.c'
--- test/hc_performance.c       2010-07-04 17:54:18 +0000
+++ test/hc_performance.c       2010-10-18 16:59:51 +0000
@@ -1,7 +1,5 @@
-/**
- * @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -65,14 +63,14 @@
             "-n [NUM] = do NUM measurements\n");
 }
 
-/*!
- * \brief   Determine and print the gettimeofday time resolution.
+/**
+ * @brief   Determine and print the gettimeofday time resolution.
  *
- * \author      Tobias Heer
+ * @author      Tobias Heer
  *
  * Determine the time resolution of gettimeofday.
  *
- * \return void
+ * @return void
  */
 static void print_timeres(void)
 {

=== added directory 'test/lib'
=== added directory 'test/lib/core'
=== added file 'test/lib/core/hit.c'
--- test/lib/core/hit.c 1970-01-01 00:00:00 +0000
+++ test/lib/core/hit.c 2010-10-24 21:00:00 +0000
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file
+ * @author Stefan Goetz <stefan.goetz@xxxxxxxxxxxxxxxxx>
+ */
+#include <check.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include "lib/core/hit.h"
+
+START_TEST(test_hip_convert_hit_to_str_valid)
+{
+    char buf[64];
+    hip_hit_t hit;
+    fail_unless(hip_convert_hit_to_str(&hit, "", buf) == 0, NULL);
+}
+END_TEST
+
+START_TEST(test_hip_convert_hit_to_str_null_hit)
+{
+    char buf[64];
+    fail_unless(hip_convert_hit_to_str(NULL, "", buf) < 0, NULL);
+}
+END_TEST
+
+START_TEST(test_hip_convert_hit_to_str_null_buf)
+{
+    hip_hit_t hit;
+    fail_unless(hip_convert_hit_to_str(&hit, "", NULL) < 0, NULL);
+}
+END_TEST
+
+START_TEST(test_hip_convert_hit_to_str_null_suffix)
+{
+    char buf[64];
+    hip_hit_t hit;
+    fail_unless(hip_convert_hit_to_str(&hit, NULL, buf) == 0, NULL);
+}
+END_TEST
+
+START_TEST(test_hip_convert_hit_to_str_bounds)
+{
+    const char suffix[] = "SFX";
+    const unsigned int BEFORE_LEN = 30;
+    const unsigned int HIT_LEN = 39; // 16 bytes -> 32 hex chars + 7 ':'s
+    const unsigned int SUFFIX_LEN = sizeof(suffix); // includes null char
+    const unsigned int AFTER_LEN = 30;
+    struct {
+        char before[BEFORE_LEN];
+        char hit[HIT_LEN];
+        char suffix[SUFFIX_LEN];
+        char after[AFTER_LEN];
+    } buf;
+    char ones[sizeof(buf)];
+    hip_hit_t hit;
+
+    memset(&buf, 1, sizeof(buf));
+    memset(ones, 1, sizeof(ones));
+    memset(&hit.s6_addr, 0x22, sizeof(hit.s6_addr));
+
+    // write the HIT string into the middle of the buffer
+    fail_unless(hip_convert_hit_to_str(&hit, suffix, buf.hit) == 0, NULL);
+    // is the buffer before the HIT untouched?
+    fail_unless(memcmp(&buf.before, ones, BEFORE_LEN) == 0, NULL);
+    // is the first part of the HIT correct?
+    fail_unless(buf.hit[0] == '2', NULL);
+    // is the last part of the HIT correct?
+    fail_unless(buf.hit[HIT_LEN - 1] == '2', NULL);
+    // is the suffix correct including the terminating null character?
+    fail_unless(memcmp(&buf.suffix, suffix, SUFFIX_LEN) == 0, NULL);
+    // is the buffer after the suffix untouched?
+    fail_unless(memcmp(&buf.after, ones, AFTER_LEN) == 0, NULL);
+}
+END_TEST
+
+START_TEST(test_hip_hit_is_bigger_bigger)
+{
+    const hip_hit_t bigger = IN6ADDR_LOOPBACK_INIT;
+    const hip_hit_t smaller = IN6ADDR_ANY_INIT;
+    fail_unless(hip_hit_is_bigger(&bigger, &smaller) == 1, NULL);
+}
+END_TEST
+
+START_TEST(test_hip_hit_is_bigger_equal_smaller)
+{
+    const hip_hit_t bigger = IN6ADDR_LOOPBACK_INIT;
+    const hip_hit_t smaller = IN6ADDR_ANY_INIT;
+    fail_unless(hip_hit_is_bigger(&smaller, &bigger) == 0, NULL);
+    fail_unless(hip_hit_is_bigger(&bigger, &bigger) == 0, NULL);
+}
+END_TEST
+
+START_TEST(test_hip_hit_is_bigger_null_first)
+{
+    const hip_hit_t hit = IN6ADDR_LOOPBACK_INIT;
+    hip_hit_is_bigger(NULL, &hit);
+}
+END_TEST
+
+START_TEST(test_hip_hit_is_bigger_null_second)
+{
+    const hip_hit_t hit = IN6ADDR_LOOPBACK_INIT;
+    hip_hit_is_bigger(&hit, NULL);
+}
+END_TEST
+
+START_TEST(test_hip_hit_is_bigger_first_null)
+{
+    hip_hit_t hit;
+    hip_hit_is_bigger(NULL, &hit);
+}
+END_TEST
+
+START_TEST(test_hip_hit_is_bigger_second_null)
+{
+    hip_hit_t hit;
+    hip_hit_is_bigger(&hit, NULL);
+}
+END_TEST
+
+// For unknown reasons, this file does not compile with the following,
+// seemingly useless forward declaration
+Suite *lib_core_hit(void);
+
+Suite *lib_core_hit(void)
+{
+    Suite *s = suite_create("lib/core/hit");
+
+    TCase *tc_core = tcase_create("Core");
+    tcase_add_test(tc_core, test_hip_convert_hit_to_str_valid);
+    tcase_add_test(tc_core, test_hip_convert_hit_to_str_null_hit);
+    tcase_add_test(tc_core, test_hip_convert_hit_to_str_null_buf);
+    tcase_add_test(tc_core, test_hip_convert_hit_to_str_null_suffix);
+    tcase_add_test(tc_core, test_hip_convert_hit_to_str_bounds);
+    tcase_add_test(tc_core, test_hip_hit_is_bigger_bigger);
+    tcase_add_test(tc_core, test_hip_hit_is_bigger_equal_smaller);
+    tcase_add_exit_test(tc_core, test_hip_hit_is_bigger_null_first, 1);
+    tcase_add_exit_test(tc_core, test_hip_hit_is_bigger_null_second, 1);
+    tcase_add_exit_test(tc_core, test_hip_hit_is_bigger_first_null, 1);
+    tcase_add_exit_test(tc_core, test_hip_hit_is_bigger_second_null, 1);
+    suite_add_tcase(s, tc_core);
+
+    return s;
+}
+

=== added file 'test/lib/core/straddr.c'
--- test/lib/core/straddr.c     1970-01-01 00:00:00 +0000
+++ test/lib/core/straddr.c     2010-10-19 12:01:36 +0000
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file
+ * @author Stefan Goetz <stefan.goetz@xxxxxxxxxxxxxxxxx>
+ */
+#include <check.h>
+#include <stdlib.h> // free()
+#include "lib/core/straddr.h"
+
+START_TEST(test_hip_in6_ntop_valid)
+{
+    const int GUARD_SIZE = 32;      // arbitrary
+    struct buf_test {
+        char before[GUARD_SIZE];
+        char addr[39];              // 16 IPv6 bytes -> 32 hex chars + 7 ':'s
+        char null[1];               // terminating null character
+        char after[GUARD_SIZE];
+    } buf;
+    char ones[GUARD_SIZE];
+    struct in6_addr in6;
+
+    memset(&buf, '1', sizeof(buf));
+    memset(ones, '1', sizeof(ones));
+    memset(&in6.s6_addr, 0x22, sizeof(in6.s6_addr));
+
+    fail_unless(hip_in6_ntop(&in6, buf.addr) == buf.addr, NULL);
+    // is the buffer before the address untouched?
+    fail_unless(memcmp(buf.before, ones, GUARD_SIZE) == 0, NULL);
+    // is the first part of the address correct?
+    fail_unless(buf.addr[0] == '2', NULL);
+    // is the last part of the address correct?
+    fail_unless(buf.addr[sizeof(buf.addr) - 1] == '2', NULL);
+    // is there a terminating null character?
+    fail_unless(buf.null[0] == '\0', NULL);
+    // is the buffer after the address untouched?
+    fail_unless(memcmp(buf.after, ones, GUARD_SIZE) == 0, NULL);
+}
+END_TEST
+
+START_TEST(test_hip_in6_ntop_null_addr)
+{
+    char buf[64];
+
+    fail_unless(hip_in6_ntop(NULL, buf) == NULL, NULL);
+}
+END_TEST
+
+START_TEST(test_hip_in6_ntop_null_buf)
+{
+    struct in6_addr in6 = IN6ADDR_LOOPBACK_INIT;
+
+    fail_unless(hip_in6_ntop(&in6, NULL) == NULL, NULL);
+}
+END_TEST
+
+START_TEST(test_hip_convert_string_to_address_valid)
+{
+    const char *str = "fe80::215:58ff:fe29:9c36";
+    struct in6_addr ip;
+
+    fail_unless(hip_convert_string_to_address(str, &ip) == 0, NULL);
+}
+END_TEST
+
+START_TEST(test_hip_convert_string_to_address_null_str)
+{
+    struct in6_addr ip;
+
+    fail_unless(hip_convert_string_to_address(NULL, &ip) < 0, NULL);
+}
+END_TEST
+
+START_TEST(test_hip_convert_string_to_address_null_addr)
+{
+    const char *str = "fe80::215:58ff:fe29:9c36";
+
+    fail_unless(hip_convert_string_to_address(str, NULL) < 0, NULL);
+}
+END_TEST
+
+START_TEST(test_hip_convert_string_to_address_invalid)
+{
+    const char *str = " fe80::215:58ff:fe29:9c36";
+    struct in6_addr ip;
+
+    fail_unless(hip_convert_string_to_address(str, &ip) < 0, NULL);
+}
+END_TEST
+
+// For unknown reasons, this file does not compile with the following,
+// seemingly useless forward declaration
+Suite *lib_core_straddr(void);
+
+Suite *lib_core_straddr(void)
+{
+    Suite *s = suite_create("lib/core/straddr");
+
+    TCase *tc_core = tcase_create("Core");
+    tcase_add_test(tc_core, test_hip_in6_ntop_valid);
+    tcase_add_test(tc_core, test_hip_in6_ntop_null_addr);
+    tcase_add_test(tc_core, test_hip_in6_ntop_null_buf);
+    tcase_add_test(tc_core, test_hip_convert_string_to_address_valid);
+    tcase_add_test(tc_core, test_hip_convert_string_to_address_null_str);
+    tcase_add_test(tc_core, test_hip_convert_string_to_address_null_addr);
+    tcase_add_test(tc_core, test_hip_convert_string_to_address_invalid);
+    suite_add_tcase(s, tc_core);
+
+    return s;
+}

=== removed directory 'tools/bzrhooks'
=== removed directory 'tools/bzrhooks/email'
=== removed file 'tools/bzrhooks/email/README'
--- tools/bzrhooks/email/README 2010-06-01 16:02:05 +0000
+++ tools/bzrhooks/email/README 1970-01-01 00:00:00 +0000
@@ -1,44 +0,0 @@
-This is a plugin which implements post commmit emails for bzr.
-
-The plugin is activated by:
- - installing it
- - configuring an address to send emails to (see ``bzr help email``).
-
-Installation
-------------
-
-To install this plug in system wide, copy it into the plugins directory of the 
bzrlib.
-You can find out the directory of the bzrlib by executing
-    bzr version | grep bzrlib
-This should be something like
-    /usr/lib/python2.6/dist-packages/bzrlib
-Then you put the plugin into
-    /usr/lib/python2.6/dist-packages/bzrlib/plugins/email
-That's all.
-
-You can check the installation by executing
-    bzr plugins
-(email plugin should be displayed with a short message)
-or
-    bzr hooks
-(post_change_branch_tip, pre_change_branch_tip should have entries from 
email-notification now)
-
-Configuration
-------------
-
-To have bzr send an email you need to configure an address to send mail
-to for that branch. To do this set the configuration option
-    commit_notification_to
-in the bazaar.conf, locations.conf or branch.conf. If there is no such address
-configured for a specific branch, no email-notifications will be sent when 
changes
-in this branch occur. Preferably, this option should be set in the branch.conf 
of each branch
-separately.
-
-The address from which the mail is sent is read from the configuration option
-    ``commit_notification_sender``
-If not supplied the name of the committer is taken as the originator.
-
-Help
-------------
-All this should be displayed too, by executing
-bzr email help

=== removed file 'tools/bzrhooks/email/__init__.py'
--- tools/bzrhooks/email/__init__.py    2010-06-01 16:02:05 +0000
+++ tools/bzrhooks/email/__init__.py    1970-01-01 00:00:00 +0000
@@ -1,134 +0,0 @@
-# Copyright (C) 2005, 2006, 2007 Canonical Ltd
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-"""Sending emails for branch changes.
-
-To have bzr send an email you need to configure an address to send mail
-to for that branch. To do this set the configuration option
-    ``commit_notification_to``
-in the bazaar.conf, locations.conf or branch.conf. If there is no such address
-configured for a specific branch, no email-notifications will be sent when 
changes
-in this branch occur.
-
-The address from which the mail is sent is read from the configuration option
-    ``commit_notification_sender``
-If not supplied the name of the committer is taken as the originator.
-
-The plugin sends email-notifications on commits and uncommits. Merges are
-displayed in a special format.
-
-Emails are sent using python's smtplib.
-
-To install this plug in system wide copy it into the plugins directory
-of the bzrlib. You can find out the directory of the bzrlib by executing
-    `` bzr version | grep bzrlib ``
-This should be something like
-    `` /usr/lib/python2.6/dist-packages/bzrlib ``
-Then you put the plugin into
-    `` /usr/lib/python2.6/dist-packages/bzrlib/plugins/email ``
-That's all.
-
-You can check the installation by executing
-    `` bzr plugins ``
-(email plugin should be displayed with a short message)
-or
-    `` bzr hooks ``
-(post_change_branch_tip, pre_change_branch_tip should have entries from 
email-notification now)
-"""
-
-
-if __name__ != 'bzrlib.plugins.email':
-    raise ImportError('The email plugin must be installed as'
-                      ' bzrlib.plugins.email not %s'
-                      % __name__)
-
-
-# These three are used during import: No point lazy_importing them.
-from bzrlib import errors
-from bzrlib.branch import Branch
-from bzrlib.smart.server import SmartTCPServer
-from bzrlib.lazy_import import lazy_import
-
-# lazy_import emailer so that it doesn't get loaded if it isn't used
-lazy_import(globals(), """\
-from bzrlib.plugins.email import emailer as _emailer
-""")
-
-def server_started_hook(backing_urls, public_urls):
-    """Detect if running as server to prevent clients from sending email 
notifications"""
-    _emailer.EmailSender.server_mode = True
-
-def post_change_branch_tip_hook(params):
-    """This hook will be called on the server's side after a change."""
-    # (branch, old_revno, new_revno, old_revid, new_revid)
-    _emailer.EmailSender(params, op='post_change').send_maybe()
-
-def pre_change_branch_tip_hook(params):
-    """This hook will be called on the server's side before a change."""
-    # (branch, old_revno, new_revno, old_revid, new_revid)
-    _emailer.EmailSender(params, op='pre_change').send_maybe()
-
-def install_hook(bzr_hook, callback, name):
-    """Install the given hook with the given name """
-    if bzr_hook in Branch.hooks:
-        install_named_hook = getattr(Branch.hooks, 'install_named_hook', None)
-        if install_named_hook is not None:
-            install_named_hook(bzr_hook, callback, name)
-        else:
-            Branch.hooks.install_hook(bzr_hook, callback)
-            if getattr(Branch.hooks, 'name_hook', None) is not None:
-                Branch.hooks.name_hook(callback, name)
-    else:
-        raise errors.BzrError("Bazaar version does not support " + bzr_hook + 
" hooks.")
-
-def install_server_hook():
-    if 'server_started' in SmartTCPServer.hooks:
-        install_named_hook = getattr(SmartTCPServer.hooks, 
'install_named_hook', None)
-        if install_named_hook is not None:
-            if 'server_started' in SmartTCPServer.hooks:
-                install_named_hook('server_started', server_started_hook, 'bzr 
email-notification')
-    else:
-        raise errors.BzrError("Bazaar version does not support server_started 
hooks.")
-
-# Install all hooks here
-def install_hooks():
-    """Install post_change_branch_tip hook """
-    install_hook('post_change_branch_tip', post_change_branch_tip_hook, 'bzr 
email-notification')
-
-    """Install pre_change_branch_tip hook """
-    install_hook('pre_change_branch_tip', pre_change_branch_tip_hook, 'bzr 
email-notification')
-
-    """ Install server_started hook """
-    install_server_hook()
-
-def test_suite():
-    from unittest import TestSuite
-    import bzrlib.plugins.email.tests
-    result = TestSuite()
-    result.addTest(bzrlib.plugins.email.tests.test_suite())
-    return result
-
-
-# setup the email plugin with > 0.15 hooks.
-try:
-    install_hooks()
-    use_legacy = False
-except AttributeError:
-    # bzr < 0.15 - no Branch.hooks
-    use_legacy = True
-except errors.UnknownHook:
-    # bzr 0.15 dev before post_commit was added
-    use_legacy = True

=== removed file 'tools/bzrhooks/email/customlogformatter.py'
--- tools/bzrhooks/email/customlogformatter.py  2010-06-01 16:02:05 +0000
+++ tools/bzrhooks/email/customlogformatter.py  1970-01-01 00:00:00 +0000
@@ -1,120 +0,0 @@
-from bzrlib import log, builtins, status
-import codecs
-
-""" A custom built subclass of log.LogFormatter.
-    Displays log of newly committed revisions in pisa style. """
-class CustomLogFormatter(log.LogFormatter):
-
-    supports_merge_revisions = True
-    preferred_levels = 1
-    supports_delta = True
-    supports_tags = True
-    supports_diff = True
-
-    def log_revision(self, revision):
-        import time
-
-        charset = 'utf-8'
-
-        """Log a revision, either merged or not."""
-        indent = u'    ' * revision.merge_depth
-        to_file = self.to_file
-
-        # Write author / commiter
-        # Only commiters are relevant for email-notification,
-        # authors are omitted.
-        try:
-            unicodestr = revision.rev.committer.decode(charset, 'replace')
-        except UnicodeError:
-            unicodestr = u"n/a due to unicode issues"
-        to_file.write(unicode(indent + 'Committer: %s\n' % (unicodestr,)))
-
-        # Write date
-        try:
-        #    date_str = osutils.format_date(revision.rev.timestamp, 
revision.rev.timezone or 0, self.show_timezone, date_fmt)
-            unicodestr = time.strftime("%d/%m/%Y at %H:%M:%S").decode(charset, 
'replace')
-        except UnicodeError:
-            unicodestr = u"n/a due to unicode issues"
-        to_file.write(unicode(indent + 'Date: %s\n' % (unicodestr,)))
-
-        # Write new revision number
-        if revision.revno is not None:
-            try:
-                unicodestr = revision.revno.decode(charset, 'replace')
-            except UnicodeError:
-                unicodestr = u"(n/a due to unicode issues)"
-            to_file.write(unicode(indent + 'Revision: %s%s\n' % (unicodestr, 
self.merge_marker(revision))))
-
-        # Always show revision id..
-        #if self.show_ids:
-        try:
-            revidstr = revision.rev.revision_id.decode(charset, 'replace')
-        except UnicodeError:
-            revidstr = u"(n/a due to unicode issues)"
-        to_file.write(unicode(indent + 'Revision-id: ' + revidstr))
-        to_file.write('\n')
-
-        # Write branch nick
-        branch_nick = revision.rev.properties.get('branch-nick', None)
-        if branch_nick is not None:
-            try:
-                unicodestr = branch_nick.decode(charset, 'replace')
-            except UnicodeError:
-                unicodestr = u"(n/a due to unicode issues)"
-            to_file.write(unicode(indent + 'Branch nick: %s\n' % 
(unicodestr,)))
-        to_file.write('\n')
-
-        # Write log message if available
-        to_file.write(indent + 'Log:\n')
-        if not revision.rev.message:
-            to_file.write(indent + '  (no log message available)\n')
-        else:
-            message = revision.rev.message.rstrip('\r\n')
-            for l in message.split('\n'):
-                try:
-                    unicodestr = l.decode(charset, 'replace')
-                except UnicodeError:
-                    unicodestr = u" xx (there were encoding issues in this 
line) xx"
-                to_file.write(indent + '  %s\n' % (unicodestr,))
-        to_file.write('\n')
-
-        # Write summary of modified files if available
-        if revision.delta is not None:
-            to_file.write(indent + 'Modified:\n')
-            revision.delta.show(to_file, self.show_ids, indent=indent+'  ', 
short_status=True)
-        else:
-            to_file.write('   ' + "revision delta not available \n")
-        to_file.write('\n')
-
-        # Write diff, only if this is not a merge
-        # If this is a merge further information will be provided by the 
emailer class
-        if revision.diff is not None and len(revision.rev.parent_ids) <= 1:
-            self.show_diff(to_file, revision.diff, indent)
-
-    def show_diff(self, to_file, diff, indent):
-        """ Show diff for files that were added and modified.
-            Diffs for files that were removed are not displayed. """
-        leaveout = False
-        charset = 'utf-8'
-        for line in diff.rstrip().split('\n'):
-            try:
-                unicodestr = line.decode(charset, 'replace')
-            except UnicodeError:
-                unicodestr = u" xx (there were encoding issues in this line) 
xx"
-
-            # Not remove/renamed case, not new file
-            if not leaveout and not line.startswith("==="):
-                to_file.write(unicode(indent + '%s\n' % (unicodestr,)))
-
-            # Start of new file, maybe remove/renamed case
-            elif line.startswith("==="):
-                parts = line.split()
-                if (parts[1] == "removed" or parts[1] == "renamed") and 
parts[2] == "file":
-                    leaveout = True
-                else:
-                    leaveout = False
-                    to_file.write(indent + '%s\n' % (unicodestr,))
-
-    def get_advice_separator(self):
-        """Get the text separating the log from the closing advice."""
-        return '-' * 60 + '\n'

=== removed file 'tools/bzrhooks/email/emailer.py'
--- tools/bzrhooks/email/emailer.py     2010-06-01 16:02:05 +0000
+++ tools/bzrhooks/email/emailer.py     1970-01-01 00:00:00 +0000
@@ -1,254 +0,0 @@
-# Copyright (C) 2005, 2006, 2007 Canonical Ltd
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-import errno
-import subprocess
-import customlogformatter as clf
-import datetime
-import time
-import sys
-import warnings
-import codecs
-
-from bzrlib import (
-    errors,
-    revision as _mod_revision,
-    log
-    )
-
-class EmailSender(object):
-    """An email message sender."""
-
-    server_mode = False
-
-    def __init__(self, params, op, local_branch=None):
-        # Extract useful information from params
-        self.config = params.branch.get_config()
-        self.branch = params.branch
-        self.new_revid = params.new_revid
-        self.old_revid = params.old_revid
-        self.new_revno = params.new_revno
-        self.old_revno = params.old_revno
-        if (local_branch is not None and 
local_branch.repository.has_revision(self.new_rev_id)):
-            self.repository = local_branch.repository
-        else:
-            self.repository = self.branch.repository
-
-        # Which hook was exectued
-        self.op = op
-
-        # Server mode?
-        self.server_mode = EmailSender.server_mode
-
-        # Which charset
-        self.charset = 'utf-8'
-
-    def setup_revision_and_revno(self):
-        """Get the revision and revision number from the branch."""
-        if self.uncommit:
-            # We want to notify about the revision that is being uncommited
-            self.revision = self.repository.get_revision(self.old_revid)
-            tmp = self.new_revid
-            self.new_revid = self.old_revid
-            self.old_revid = tmp
-            tmp = self.new_revno
-            self.new_revno = self.old_revno
-            self.old_revno = tmp
-        else:
-            self.revision = self.repository.get_revision(self.new_revid)
-
-    def get_merge_info(self):
-        """ Display some additional information if this revision is a merge """
-
-        # Get new working tree
-        tree_new = self.repository.revision_tree(self.new_revid)
-
-        # Get parent ids.. if this is a merge there are more than one.
-        parent_ids = self.repository.get_revision(self.new_revid).parent_ids
-        if len(parent_ids) <= 1:
-            return ""
-
-        # Create merge information
-        res = "Merge from following parent revisions and branches:\n"
-        for merge in parent_ids:
-            try:
-                rev = self.repository.get_revisions([merge])[0]
-                res += "  - " + rev.properties.get('branch-nick', '(branch 
nick n/a)') +"\t  (parent-id: " + merge + ")    \n"
-            except errors.NoSuchRevision:
-                # If we are missing a revision, just print out the revision id
-                res += ' (ghost) ' + merge + '\n'
-                continue
-
-        return res + "\n"
-
-    def body(self):
-        """Create the email body"""
-        from bzrlib import log
-
-        # Determine start and end revision to display
-        rev1 = rev2 = self.new_revno
-        if rev1 == 0:
-            rev1 = None
-            rev2 = None
-
-        # We must use StringIO.StringIO because we want a Unicode string that
-        # we can pass to send_email and have that do the proper encoding.
-        from StringIO import StringIO
-        outf = StringIO()
-        try:
-            enc, dec, reader, writer = codecs.lookup(self.charset)
-            writebuffer = writer(outf, 'replace')
-        except LookupError:
-            warnings.warn("Failed to lookup " + charset + "-codec. You might 
encounter further errors regarding encoding..")
-            writebuffer = outf
-
-        try:
-            # Use custom log formatter, which displays logrevisions in 
pisa-style...
-            lf = clf.CustomLogFormatter(show_ids=False, to_file=writebuffer)
-
-            # Let the show_log code do all the work
-            # set verbose = True to provide a treedelta
-            log.show_log(self.branch, lf, start_revision=rev1, 
end_revision=rev2, verbose=True, show_diff=True)
-
-            # This could be a merge, too...
-            merge_info = self.get_merge_info()
-        except UnicodeError:
-            warnings.warn("There was a unicode error...")
-
-        # If this an uncommit, write a short note
-        additional_info = ""
-        if self.uncommit:
-            additional_info = " ------- Log of revision UNCOMMITTED on " + 
time.strftime("%y/%m/%d at %H:%M:%S") + " ------- \n \n"
-
-        try:
-            logmessage = outf.getvalue()
-        except UnicodeError:
-            logmessage = "(empty due to UnicodeDecodeError) \n"
-            warnings.warn("Error while creating logmessage. Notification with 
empty revisionlog will be sent!")
-
-        return additional_info + logmessage + merge_info
-
-    def to_address(self):
-        """What is the address the mail should go to."""
-        return self.config.get_user_option('commit_notification_to')
-
-    def from_address(self):
-        """What address should I send from."""
-        # On default the commiter is the sender,
-        # overwrite this by setting post_commit_sender in bazaar.conf or 
branch.conf
-        result = self.config.get_user_option('commit_notification_sender')
-        if result is None:
-            result = self.repository.get_revision(self.new_revid).committer
-
-        return result
-
-    def send(self):
-        """Send the email."""
-        self.branch.lock_read()
-        self.repository.lock_read()
-        try:
-            self._send_using_smtplib()
-        finally:
-            self.repository.unlock()
-            self.branch.unlock()
-
-    def _send_using_smtplib(self):
-        """Use python's smtplib to send the email."""
-        import smtplib
-        from email.mime.text import MIMEText
-
-
-        # Encode message body
-        try:
-            body = self.body().encode(self.charset)
-        except UnicodeEncodeError:
-            warnings.warn("Could not encode email body. No notification sent!")
-            return
-
-        # Create the email
-        try:
-            message = MIMEText(body, 'plain', self.charset)
-        except TypeError:
-            warnings.warn("Could not create email. No notification sent!")
-            return
-
-        message['Subject'] = self.subject()
-        message['From'] = self.from_address()
-        message['To'] = self.to_address()
-
-        # Send the message via our own SMTP server, but don't include the
-        # envelope header.
-        try:
-            server = smtplib.SMTP('localhost')
-        except:
-            warnings.warn("Could not connect to local mailserver. No 
notification sent!")
-            return
-
-        # Send the mail
-        server.sendmail(self.from_address(), self.to_address(), 
message.as_string())
-        server.quit()
-
-    def should_send(self):
-        """Determine if a notification should be sent at the present point.
-
-           Only send if running as server.
-
-           If called from pre_change_branch_tip hook we only want to send a 
mail if this is an uncommit.
-           If called from post_change_branch_tip hook we want to send a mail 
if this is a commit or merge.
-        """
-
-        # Determine whether this is an uncommit and set up revision, revision 
ids and revision numbers accordingly
-        if (self.new_revno - self.old_revno) > 0:
-            self.uncommit = False
-        else:
-            self.uncommit = True
-        self.setup_revision_and_revno()
-
-        # Server mode is not running as the server_started hook doesn't get 
fired,
-        # so this feature is disabled
-        # A client should not send mails, as this is supposed to run on a 
server.
-        # if not self.server_mode:
-        #    return False
-
-        # If pre_change_branch_tip hook is exectued on something not an 
uncommit
-        if (self.op == 'pre_change' and not self.uncommit):
-            return False
-
-        # If post_change_branch_tip hook is exectued on an uncommit
-        if (self.op == 'post_change' and self.uncommit):
-            return False
-
-        # Only send if to- and from-address is known
-        # Don't set at least one of these in order to disable 
email-notification.
-        return bool(self.to_address() and self.from_address())
-
-    def send_maybe(self):
-        if self.should_send():
-            self.send()
-
-
-    def subject(self):
-        """Create the subject of the email notification"""
-        branch_nick = self.revision.properties.get('branch-nick','(branch nick 
n/a)')
-
-        additional_info = ""
-        if self.uncommit:
-            additional_info = "[UNCOMMIT]"
-
-        return ("[" + branch_nick + "] Rev %d: %s %s" %
-                (self.new_revno,
-                 self.revision.get_summary(),
-                 additional_info))

=== removed file 'tools/bzrhooks/email/setup.py'
--- tools/bzrhooks/email/setup.py       2010-06-01 16:02:05 +0000
+++ tools/bzrhooks/email/setup.py       1970-01-01 00:00:00 +0000
@@ -1,21 +0,0 @@
-#!/usr/bin/env python2.4
-
-from distutils.core import setup
-
-setup(name='bzr-email',
-      description='Email plugin for Bazaar',
-      keywords='plugin bzr email',
-      version='0.0.1',
-      url='http://launchpad.net/bzr-email',
-      download_url='http://launchpad.net/bzr-email',
-      license='GPL',
-      author='Robert Collins',
-      author_email='robertc@xxxxxxxxxxxxxxxxx',
-      long_description="""
-      Hooks into Bazaar and sends commit notification emails
-      """,
-      package_dir={'bzrlib.plugins.email':'.',
-                   'bzrlib.plugins.email.tests':'tests'},
-      packages=['bzrlib.plugins.email',
-                'bzrlib.plugins.email.tests']
-      )

=== removed directory 'tools/bzrhooks/email/tests'
=== removed file 'tools/bzrhooks/email/tests/__init__.py'
--- tools/bzrhooks/email/tests/__init__.py      2010-06-01 16:02:05 +0000
+++ tools/bzrhooks/email/tests/__init__.py      1970-01-01 00:00:00 +0000
@@ -1,29 +0,0 @@
-# Copyright (C) 2005 by Canonical Ltd
-#   Authors: Robert Collins <robert.collins@xxxxxxxxxxxxx>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-from unittest import TestLoader, TestSuite
-
-def test_suite():
-    result = TestSuite()
-    import testemail
-    import test_smtp_connection
-
-    loader = TestLoader()
-    result.addTests(loader.loadTestsFromModule(testemail))
-    result.addTests(loader.loadTestsFromModule(test_smtp_connection))
-    return result
-

=== removed file 'tools/bzrhooks/email/tests/test_smtp_connection.py'
--- tools/bzrhooks/email/tests/test_smtp_connection.py  2010-06-01 16:02:05 
+0000
+++ tools/bzrhooks/email/tests/test_smtp_connection.py  1970-01-01 00:00:00 
+0000
@@ -1,299 +0,0 @@
-# Copyright (C) 2005 by Canonical Ltd
-#   Authors: Robert Collins <robert.collins@xxxxxxxxxxxxx>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-from cStringIO import StringIO
-
-from bzrlib import (
-    config,
-    __version__ as _bzrlib_version,
-    )
-from bzrlib.tests import TestCase
-from bzrlib.plugins.email.smtp_connection import SMTPConnection
-
-
-class InstrumentedSMTPConnection(SMTPConnection):
-    """Instrument SMTPConnection.
-
-    We don't want to actually connect or send messages, so this just
-    fakes it.
-    """
-
-    class FakeSMTP(object):
-        """Fakes an SMTP connection."""
-
-        def __init__(self, actions):
-            self.actions = actions
-
-        def sendmail(self, from_addr, to_addrs, msg):
-            self.actions.append(('sendmail', from_addr, to_addrs, msg))
-
-        def login(self, username, password):
-            self.actions.append(('login', username, password))
-
-    def __init__(self, config):
-        super(InstrumentedSMTPConnection, self).__init__(config)
-        self.actions = []
-
-    def _create_connection(self):
-        self.actions.append(('create_connection',))
-        self._connection = InstrumentedSMTPConnection.FakeSMTP(self.actions)
-
-    def _basic_message(self, *args, **kwargs):
-        """Override to force the boundary for easier testing."""
-        msg, from_email, to_emails = super(InstrumentedSMTPConnection,
-        self)._basic_message(*args, **kwargs)
-        msg.set_boundary('=====123456==')
-        return msg, from_email, to_emails
-
-
-class TestSMTPConnection(TestCase):
-
-    def get_connection(self, text):
-        my_config = config.GlobalConfig()
-        config_file = StringIO(text)
-        my_config._get_parser(config_file)
-        return InstrumentedSMTPConnection(my_config)
-
-    def test_defaults(self):
-        conn = self.get_connection('')
-        self.assertEqual('localhost', conn._smtp_server)
-        self.assertEqual(None, conn._smtp_username)
-        self.assertEqual(None, conn._smtp_password)
-
-    def test_smtp_server(self):
-        conn = self.get_connection('[DEFAULT]\nsmtp_server=host:10\n')
-        self.assertEqual('host:10', conn._smtp_server)
-
-    def test_smtp_username(self):
-        conn = self.get_connection('')
-        self.assertIs(None, conn._smtp_username)
-
-        conn = self.get_connection('[DEFAULT]\nsmtp_username=joebody\n')
-        self.assertEqual(u'joebody', conn._smtp_username)
-
-    def test_smtp_password(self):
-        conn = self.get_connection('')
-        self.assertIs(None, conn._smtp_password)
-
-        conn = self.get_connection('[DEFAULT]\nsmtp_password=mypass\n')
-        self.assertEqual(u'mypass', conn._smtp_password)
-
-    def assertSplitEquals(self, username, email, address):
-        actual = SMTPConnection._split_address(address)
-        self.assertEqual((username, email), actual)
-
-    def test__split_address(self):
-        self.assertSplitEquals(u'Joe Foo', 'joe@xxxxxxx',
-                               u'Joe Foo <joe@xxxxxxx>')
-        self.assertSplitEquals(u'Joe F\xb5', 'joe@xxxxxxx',
-                               u'Joe F\xb5 <joe@xxxxxxx>')
-        self.assertSplitEquals('', 'joe', 'joe')
-
-    def test_simple_send(self):
-        """Test that we build up a reasonable looking email.
-
-        This also tests that we extract the right email addresses, etc, and it
-        gets passed to sendmail() with the right parameters.
-        """
-        conn = self.get_connection('')
-        from_addr = u'Jerry F\xb5z <jerry@xxxxxxxx>'
-        to_addr = u'Biz N\xe5 <biz@xxxxxx>'
-        subject = u'Hello Biz N\xe5'
-        message=(u'Hello Biz N\xe5\n'
-                 u'I haven\'t heard\n'
-                 u'from you in a while\n')
-        conn.send_text_email(from_addr, [to_addr], subject, message)
-        self.assertEqual(('create_connection',), conn.actions[0])
-        self.assertEqual(('sendmail', 'jerry@xxxxxxxx', ['biz@xxxxxx']),
-                         conn.actions[1][:3])
-        self.assertEqualDiff((
-   'Content-Type: multipart/mixed; boundary="=====123456=="\n'
-   'MIME-Version: 1.0\n'
-   'From: =?utf-8?q?Jerry_F=C2=B5z?= <jerry@xxxxxxxx>\n'
-   'User-Agent: bzr/%s\n'
-   'To: =?utf-8?q?Biz_N=C3=A5?= <biz@xxxxxx>\n'
-   'Subject: =?utf-8?q?Hello_Biz_N=C3=A5?=\n'
-   '\n'
-   '--=====123456==\n'
-   'Content-Type: text/plain; charset="utf-8"\n'
-   'MIME-Version: 1.0\n'
-   'Content-Transfer-Encoding: base64\n'
-   '\n'
-   'SGVsbG8gQml6IE7DpQpJIGhhdmVuJ3QgaGVhcmQKZnJvbSB5b3UgaW4gYSB3aGlsZQo=\n'
-   '\n'
-   '--=====123456==--'
-   ) % _bzrlib_version, conn.actions[1][3])
-
-    def test_send_text_and_attachment_email(self):
-        conn = self.get_connection('')
-        from_addr = u'Jerry F\xb5z <jerry@xxxxxxxx>'
-        to_addr = u'Biz N\xe5 <biz@xxxxxx>'
-        subject = u'Hello Biz N\xe5'
-        message=(u'Hello Biz N\xe5\n'
-                 u'See my attached patch\n')
-        diff_txt = ('=== diff contents\n'
-                    '--- old\n'
-                    '+++ new\n'
-                    ' unchanged\n'
-                    '-old binary\xb5\n'
-                    '-new binary\xe5\n'
-                    ' unchanged\n')
-        conn.send_text_and_attachment_email(from_addr, [to_addr], subject,
-                                            message, diff_txt, 'test.diff')
-        self.assertEqual(('create_connection',), conn.actions[0])
-        self.assertEqual(('sendmail', 'jerry@xxxxxxxx', ['biz@xxxxxx']),
-                         conn.actions[1][:3])
-        self.assertEqualDiff((
-   'Content-Type: multipart/mixed; boundary="=====123456=="\n'
-   'MIME-Version: 1.0\n'
-   'From: =?utf-8?q?Jerry_F=C2=B5z?= <jerry@xxxxxxxx>\n'
-   'User-Agent: bzr/%s\n'
-   'To: =?utf-8?q?Biz_N=C3=A5?= <biz@xxxxxx>\n'
-   'Subject: =?utf-8?q?Hello_Biz_N=C3=A5?=\n'
-   '\n'
-   '--=====123456==\n'
-   'Content-Type: text/plain; charset="utf-8"\n'
-   'MIME-Version: 1.0\n'
-   'Content-Transfer-Encoding: base64\n'
-   '\n'
-   'SGVsbG8gQml6IE7DpQpTZWUgbXkgYXR0YWNoZWQgcGF0Y2gK\n'
-   '\n'
-   '--=====123456==\n'
-   'Content-Type: text/plain; charset="8-bit"; name="test.diff"\n'
-   'MIME-Version: 1.0\n'
-   'Content-Transfer-Encoding: base64\n'
-   'Content-Disposition: inline; filename="test.diff"\n'
-   '\n'
-   
'PT09IGRpZmYgY29udGVudHMKLS0tIG9sZAorKysgbmV3CiB1bmNoYW5nZWQKLW9sZCBiaW5hcnm1\n'
-   'Ci1uZXcgYmluYXJ55QogdW5jaGFuZ2VkCg==\n'
-   '\n'
-   '--=====123456==--'
-   ) % _bzrlib_version, conn.actions[1][3])
-
-    def test_create_and_send(self):
-        """Test that you can create a custom email, and send it."""
-        conn = self.get_connection('')
-        email_msg, from_email, to_emails = conn.create_email(
-            'Joe Foo <joe@xxxxxxx>',
-            ['Jane Foo <jane@xxxxxxx>', 'Barry Foo <barry@xxxxxxx>'],
-            'Hi Jane and Barry',
-            'Check out the attachment\n')
-        self.assertEqual('joe@xxxxxxx', from_email)
-        self.assertEqual(['jane@xxxxxxx', 'barry@xxxxxxx'], to_emails)
-
-        try:
-            # python 2.5
-            from email.mime.nonmultipart import MIMENonMultipart
-            from email.encoders import encode_base64
-        except ImportError:
-            # python 2.4
-            from email.MIMENonMultipart import MIMENonMultipart
-            from email.Encoders import encode_base64
-
-        attachment_txt = '\x00foo\xff\xff\xff\xff'
-        attachment = MIMENonMultipart('application', 'octet-stream')
-        attachment.set_payload(attachment_txt)
-        encode_base64(attachment)
-
-        email_msg.attach(attachment)
-
-        # This will add someone to send to, but not include it in the To list.
-        to_emails.append('b@xxxxxx')
-        conn.send_email(email_msg, from_email, to_emails)
-
-        self.assertEqual(('create_connection',), conn.actions[0])
-        self.assertEqual(('sendmail', 'joe@xxxxxxx',
-                          ['jane@xxxxxxx', 'barry@xxxxxxx', 'b@xxxxxx']),
-                         conn.actions[1][:3])
-        self.assertEqualDiff((
-   'Content-Type: multipart/mixed; boundary="=====123456=="\n'
-   'MIME-Version: 1.0\n'
-   'From: Joe Foo <joe@xxxxxxx>\n'
-   'User-Agent: bzr/%s\n'
-   'To: Jane Foo <jane@xxxxxxx>, Barry Foo <barry@xxxxxxx>\n'
-   'Subject: Hi Jane and Barry\n'
-   '\n'
-   '--=====123456==\n'
-   'Content-Type: text/plain; charset="utf-8"\n'
-   'MIME-Version: 1.0\n'
-   'Content-Transfer-Encoding: base64\n'
-   '\n'
-   'Q2hlY2sgb3V0IHRoZSBhdHRhY2htZW50Cg==\n'
-   '\n'
-   '--=====123456==\n'
-   'Content-Type: application/octet-stream\n'
-   'MIME-Version: 1.0\n'
-   'Content-Transfer-Encoding: base64\n'
-   '\n'
-   'AGZvb/////8=\n'
-   '--=====123456==--'
-   ) % _bzrlib_version, conn.actions[1][3])
-
-    def test_email_parse(self):
-        """Check that python's email can parse our emails."""
-        conn = self.get_connection('')
-        from_addr = u'Jerry F\xb5z <jerry@xxxxxxxx>'
-        to_addr = u'Biz N\xe5 <biz@xxxxxx>'
-        subject = u'Hello Biz N\xe5'
-        message=(u'Hello Biz N\xe5\n'
-                 u'See my attached patch\n')
-        diff_txt = ('=== diff contents\n'
-                    '--- old\n'
-                    '+++ new\n'
-                    ' unchanged\n'
-                    '-old binary\xb5\n'
-                    '-new binary\xe5\n'
-                    ' unchanged\n')
-        conn.send_text_and_attachment_email(from_addr, [to_addr], subject,
-                                            message, diff_txt, 'test.diff')
-        self.assertEqual(('create_connection',), conn.actions[0])
-        self.assertEqual(('sendmail', 'jerry@xxxxxxxx', ['biz@xxxxxx']),
-                         conn.actions[1][:3])
-        email_message_text = conn.actions[1][3]
-
-        try:
-            # python 2.5
-            from email.parser import Parser
-            from email.header import decode_header
-        except ImportError:
-            # python 2.4
-            from email.Parser import Parser
-            from email.Header import decode_header
-
-        def decode(s):
-            """Convert a header string to a unicode string.
-
-            This handles '=?utf-8?q?foo=C2=B5?=' => u'Foo\\xb5'
-            """
-            return ' '.join([chunk.decode(encoding or 'ascii')
-                             for chunk, encoding in decode_header(s)])
-
-        p = Parser()
-        email_message = p.parsestr(email_message_text)
-
-        self.assertEqual(from_addr, decode(email_message['From']))
-        self.assertEqual(to_addr, decode(email_message['To']))
-        self.assertEqual(subject, decode(email_message['Subject']))
-        text_payload = email_message.get_payload(0)
-        diff_payload = email_message.get_payload(1)
-        # I haven't found a way to have python's email read the charset=""
-        # portion of the Content-Type header. So I'm doing it manually
-        # The 'decode=True' here means to decode from base64 => 8-bit text.
-        # text_payload.get_charset() returns None
-        text = text_payload.get_payload(decode=True).decode('utf-8')
-        self.assertEqual(message, text)
-        self.assertEqual(diff_txt, diff_payload.get_payload(decode=True))

=== removed file 'tools/bzrhooks/email/tests/testemail.py'
--- tools/bzrhooks/email/tests/testemail.py     2010-06-01 16:02:05 +0000
+++ tools/bzrhooks/email/tests/testemail.py     1970-01-01 00:00:00 +0000
@@ -1,216 +0,0 @@
-# Copyright (C) 2005 by Canonical Ltd
-#   Authors: Robert Collins <robert.collins@xxxxxxxxxxxxx>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-from cStringIO import StringIO
-from unittest import TestLoader
-
-from bzrlib import (
-    config,
-    tests,
-    )
-from bzrlib.bzrdir import BzrDir
-from bzrlib.tests import TestCaseInTempDir
-from bzrlib.plugins.email import post_commit
-from bzrlib.plugins.email.emailer import EmailSender
-
-
-def test_suite():
-    return TestLoader().loadTestsFromName(__name__)
-
-
-sample_config=("[DEFAULT]\n"
-               "post_commit_to=demo@xxxxxxxxxxx\n"
-               "post_commit_sender=Sample <foo@xxxxxxxxxxx>\n")
-
-unconfigured_config=("[DEFAULT]\n"
-                     "email=Robert <foo@xxxxxxxxxxx>\n")
-
-sender_configured_config=("[DEFAULT]\n"
-                          "post_commit_sender=Sample <foo@xxxxxxxxxxx>\n")
-
-to_configured_config=("[DEFAULT]\n"
-                      "post_commit_to=Sample <foo@xxxxxxxxxxx>\n")
-
-multiple_to_configured_config=("[DEFAULT]\n"
-              "post_commit_sender=Sender <from@xxxxxxxxxxx>\n"
-              "post_commit_to=Sample <foo@xxxxxxxxxxx>, Other <baz@xxxxxxx>\n")
-
-push_config=("[DEFAULT]\n"
-    "post_commit_to=demo@xxxxxxxxxxx\n"
-    "post_commit_push_pull=True\n")
-
-with_url_config=("[DEFAULT]\n"
-                 "post_commit_url=http://some.fake/url/\n";
-                 "post_commit_to=demo@xxxxxxxxxxx\n"
-                 "post_commit_sender=Sample <foo@xxxxxxxxxxx>\n")
-
-
-class TestGetTo(TestCaseInTempDir):
-
-    def test_body(self):
-        sender = self.get_sender()
-        # FIXME: this should not use a literal log, rather grab one from 
bzrlib.log
-        self.assertEqual(
-            'At %s\n'
-            '\n'
-            '------------------------------------------------------------\n'
-            'revno: 1\n'
-            'revision-id: A\n'
-            'committer: Sample <john@xxxxxxxxxxx>\n'
-            'branch nick: work\n'
-            'timestamp: Thu 1970-01-01 00:00:01 +0000\n'
-            'message:\n'
-            '  foo bar baz\n'
-            '  fuzzy\n'
-            '  wuzzy\n' % sender.url(), sender.body())
-
-    def test_command_line(self):
-        sender = self.get_sender()
-        self.assertEqual(['mail', '-s', sender.subject(), '-a',
-                          'From: ' + sender.from_address(), sender.to()],
-                         sender._command_line())
-
-    def test_to(self):
-        sender = self.get_sender()
-        self.assertEqual('demo@xxxxxxxxxxx', sender.to())
-
-    def test_from(self):
-        sender = self.get_sender()
-        self.assertEqual('Sample <foo@xxxxxxxxxxx>', sender.from_address())
-
-    def test_from_default(self):
-        sender = self.get_sender(unconfigured_config)
-        self.assertEqual('Robert <foo@xxxxxxxxxxx>', sender.from_address())
-
-    def test_should_send(self):
-        sender = self.get_sender()
-        self.assertEqual(True, sender.should_send())
-
-    def test_should_not_send(self):
-        sender = self.get_sender(unconfigured_config)
-        self.assertEqual(False, sender.should_send())
-
-    def test_should_not_send_sender_configured(self):
-        sender = self.get_sender(sender_configured_config)
-        self.assertEqual(False, sender.should_send())
-
-    def test_should_not_send_to_configured(self):
-        sender = self.get_sender(to_configured_config)
-        self.assertEqual(True, sender.should_send())
-
-    def test_send_to_multiple(self):
-        sender = self.get_sender(multiple_to_configured_config)
-        self.assertEqual([u'Sample <foo@xxxxxxxxxxx>', u'Other <baz@xxxxxxx>'],
-                         sender.to())
-        self.assertEqual([u'Sample <foo@xxxxxxxxxxx>', u'Other <baz@xxxxxxx>'],
-                         sender._command_line()[-2:])
-
-    def test_url_set(self):
-        sender = self.get_sender(with_url_config)
-        self.assertEqual(sender.url(), 'http://some.fake/url/')
-
-    def test_public_url_set(self):
-        config=("[DEFAULT]\n"
-                "public_branch=http://the.publication/location/\n";)
-        sender = self.get_sender(config)
-        self.assertEqual(sender.url(), 'http://the.publication/location/')
-
-    def test_url_precedence(self):
-        config=("[DEFAULT]\n"
-                "post_commit_url=http://some.fake/url/\n";
-                "public_branch=http://the.publication/location/\n";)
-        sender = self.get_sender(config)
-        self.assertEqual(sender.url(), 'http://some.fake/url/')
-
-    def test_url_unset(self):
-        sender = self.get_sender()
-        self.assertEqual(sender.url(), sender.branch.base)
-
-    def test_subject(self):
-        sender = self.get_sender()
-        self.assertEqual("Rev 1: foo bar baz in %s" %
-                            sender.branch.base,
-                         sender.subject())
-
-    def test_diff_filename(self):
-        sender = self.get_sender()
-        self.assertEqual('patch-1.diff', sender.diff_filename())
-
-    def get_sender(self, text=sample_config):
-        self.branch = BzrDir.create_branch_convenience('.')
-        tree = self.branch.bzrdir.open_workingtree()
-        tree.commit('foo bar baz\nfuzzy\nwuzzy', rev_id='A',
-            allow_pointless=True,
-            timestamp=1,
-            timezone=0,
-            committer="Sample <john@xxxxxxxxxxx>",
-            )
-        my_config = self.branch.get_config()
-        config_file = StringIO(text)
-        (my_config._get_global_config()._get_parser(config_file))
-        sender = EmailSender(self.branch, 'A', my_config)
-        # This is usually only done after the EmailSender has locked the branch
-        # and repository during send(), however, for testing, we need to do it
-        # earlier, since send() is not called.
-        sender._setup_revision_and_revno()
-        return sender
-
-
-class TestEmailerWithLocal(tests.TestCaseWithTransport):
-    """Test that Emailer will use a local branch if supplied."""
-
-    def test_local_has_revision(self):
-        master_tree = self.make_branch_and_tree('master')
-        self.build_tree(['master/a'])
-        master_tree.add('a')
-        master_tree.commit('a')
-
-        child_tree = master_tree.bzrdir.sprout('child').open_workingtree()
-        child_tree.branch.bind(master_tree.branch)
-
-        self.build_tree(['child/b'])
-        child_tree.add(['b'])
-        revision_id = child_tree.commit('b')
-
-        sender = EmailSender(master_tree.branch, revision_id,
-                             master_tree.branch.get_config(),
-                             local_branch=child_tree.branch)
-
-        # Make sure we are using the 'local_branch' repository, and not the
-        # remote one.
-        self.assertIs(child_tree.branch.repository, sender.repository)
-
-    def test_local_missing_revision(self):
-        master_tree = self.make_branch_and_tree('master')
-        self.build_tree(['master/a'])
-        master_tree.add('a')
-        master_tree.commit('a')
-
-        child_tree = master_tree.bzrdir.sprout('child').open_workingtree()
-        child_tree.branch.bind(master_tree.branch)
-
-        self.build_tree(['master/c'])
-        master_tree.add(['c'])
-        revision_id = master_tree.commit('c')
-
-        self.failIf(child_tree.branch.repository.has_revision(revision_id))
-        sender = EmailSender(master_tree.branch, revision_id,
-                             master_tree.branch.get_config(),
-                             local_branch=child_tree.branch)
-        # We should be using the master repository here, because the child
-        # repository doesn't contain the revision.
-        self.assertIs(master_tree.branch.repository, sender.repository)

=== removed directory 'tools/bzrhooks/syntaxchecker'
=== removed file 'tools/bzrhooks/syntaxchecker/__init__.py'
--- tools/bzrhooks/syntaxchecker/__init__.py    2010-06-01 16:02:05 +0000
+++ tools/bzrhooks/syntaxchecker/__init__.py    1970-01-01 00:00:00 +0000
@@ -1,119 +0,0 @@
-# Copyright (C) 2005, 2006, 2007 Canonical Ltd
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-""" Plugin to avoid committing undesired text.
-
-* The plugin will reject all patches that contain tabs, trailing whitespaces 
or long lines.
-
-* Files that are allowed to contain these patterns can be specified in the 
user options
-    - syntax_dontcheck_tabs
-    - syntax_dontcheck_longlines
-    - syntax_dontcheck_whitespaces
-    - syntax_dontcheck_newlines
-F.e.
-    - syntax_ignorelist_tabs = file1.c,file2.c
-    - syntax_ignorelist_longlines = *.c
-    - syntax_ignorelist_whitespaces =
-    - syntax_ignorelist_newlines = *.c,Makefile.am
-  If one of the option is not set, this test will be disabled
-  Attention: On the contrary, specifying an empty list, will result in every 
file being checked.
-  In the patterns you can use unix shell-style wildcards, which are not the 
same as regular expressions
-  The special characters used in shell-style wildcards are:
-    *  which matches everything
-    ?  which matches any single character
-    [seq] which matches any character in seq
-    [!seq] which matches any character not in seq
-  Note that the filename separator ('/' on Unix) is not special here.
-  Neither are filenames starting with a period. They are equally matched by 
the * and ? patterns.
-  (for further details see documentation of pythons fnmatch module)
-
-* The maximal length of lines is read from useroption
-    - syntax_longline_length
-  It is set to 80 if not specified.
-
-* To install this plug in system wide copy it into the plugins directory
-  of the bzrlib. You can find out the directory of the bzrlib by executing
-    `` bzr version | grep bzrlib ``
-  This should be something like
-    `` /usr/lib/python2.6/dist-packages/bzrlib ``
-  Then you put the plugin into
-    `` /usr/lib/python2.6/dist-packages/bzrlib/plugins/syntaxchecker ``
-  That's all.
-
-* You can check the installation by executing
-    `` bzr plugins ``
-  (syntaxchecker plugin should be displayed with a short message)
-  or
-    `` bzr hooks ``
-  (pre_change_branch_tip should have an entry from syntaxchecker now)
-"""
-
-
-if __name__ != 'bzrlib.plugins.syntaxchecker':
-    raise ImportError('The syntaxchecker plugin must be installed as'
-                      ' bzrlib.plugins.syntaxchecker not %s'
-                      % __name__)
-
-
-# These three are used during import: No point lazy_importing them.
-from bzrlib import errors
-from bzrlib.branch import Branch
-from bzrlib.lazy_import import lazy_import
-
-# lazy_import emailer so that it doesn't get loaded if it isn't used
-lazy_import(globals(), """\
-from bzrlib.plugins.syntaxchecker import syntaxchecker as _syntaxchecker
-""")
-
-def pre_change_branch_tip_hook(params):
-    """This hook will be called on the server's side before a change."""
-    # (branch, old_revno, new_revno, old_revid, new_revid)
-    _syntaxchecker.SyntaxChecker(params).check()
-
-def install_hook(bzr_hook, callback, name):
-    """Install the given hook with the given name """
-    if bzr_hook in Branch.hooks:
-        install_named_hook = getattr(Branch.hooks, 'install_named_hook', None)
-        if install_named_hook is not None:
-            install_named_hook(bzr_hook, callback, name)
-        else:
-            Branch.hooks.install_hook(bzr_hook, callback)
-            if getattr(Branch.hooks, 'name_hook', None) is not None:
-                Branch.hooks.name_hook(callback, name)
-    else:
-        raise errors.BzrError("Bazaar version does not support " + bzr_hook + 
" hooks.")
-
-# Install all hooks here
-def install_hooks():
-
-    """Install pre_change_branch_tip hook """
-    install_hook('pre_change_branch_tip', pre_change_branch_tip_hook, 'bzr 
syntaxchecker')
-
-
-def test_suite():
-    return
-
-
-# setup the email plugin with > 0.15 hooks.
-try:
-    install_hooks()
-    use_legacy = False
-except AttributeError:
-    # bzr < 0.15 - no Branch.hooks
-    use_legacy = True
-except errors.UnknownHook:
-    # bzr 0.15 dev before post_commit was added
-    use_legacy = True

=== removed file 'tools/bzrhooks/syntaxchecker/syntaxchecker.py'
--- tools/bzrhooks/syntaxchecker/syntaxchecker.py       2010-06-01 16:02:05 
+0000
+++ tools/bzrhooks/syntaxchecker/syntaxchecker.py       1970-01-01 00:00:00 
+0000
@@ -1,222 +0,0 @@
-# Copyright (C) 2005, 2006, 2007 Canonical Ltd
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-from bzrlib import errors
-from StringIO import StringIO
-import fnmatch
-
-class SyntaxChecker(object):
-
-    def __init__(self, params, local_branch=None):
-        """Get the revision ids, revision numbers, config and repository from 
the branch."""
-
-        self.config = params.branch.get_config()
-        self.branch = params.branch
-        self.new_revno = params.new_revno
-        self.old_revno = params.old_revno
-
-        # Get repository for new revision
-        if (local_branch is not None and 
local_branch.repository.has_revision(params.new_revid)):
-            self.repository = local_branch.repository
-        else:
-            self.repository = params.branch.repository
-
-        # Get the revision
-        self.revision = self.repository.get_revision(params.new_revid)
-
-        # Get old and new working tree
-        self.new_tree =  self.repository.revision_tree(params.new_revid)
-        self.old_tree = self.branch.basis_tree()
-
-        # Initialize ignore lists
-        self._init_ignore_lists()
-
-        # Get maximal line length
-        self.longline_length = 
self.config.get_user_option('syntax_longline_length')
-        if self.longline_length is None:
-            self.longline_length = 80
-
-    def _init_ignore_list(self, user_option):
-        """ Initialize the whitelist from the user option """
-        list = self.config.get_user_option(user_option)
-
-        # if no list is provided
-        if list is None:
-            return None
-
-        # if only one pattern is provided
-        if type(list) != type([]):
-            list = [list]
-        return list
-
-    def _init_ignore_lists(self):
-        """ Read the ignore for the different checks from the user config """
-        self.tabs_ignorelist = self._init_ignore_list('syntax_dontcheck_tabs')
-        self.whitespaces_ignorelist = 
self._init_ignore_list('syntax_dontcheck_whitespaces')
-        self.newlines_ignorelist = 
self._init_ignore_list('syntax_dontcheck_newlines')
-        self.longlines_ignorelist = 
self._init_ignore_list('syntax_dontcheck_longlines')
-        self.dosbreaks_ignorelist = 
self._init_ignore_list('syntax_dontcheck_doslinebreaks')
-
-    def _match(self, patterns, file):
-        """ Check if file matches one of the patterns in the given list of 
patterns.
-            If no list is provided then the file does match e.g. will be 
ignored"""
-
-        # If no list was provided, file is ignored per default, e.g. matches
-        if patterns is None:
-            return True
-
-        # Use unix shell-style wildcards for filename-pattern-matching
-        for pattern in patterns:
-            if fnmatch.fnmatch(file, pattern):
-                return True
-
-        return False
-
-    def _get_tests(self, path):
-        """ Return a list of tests to perform on the given file """
-        tests = {}
-        if not self._match(self.tabs_ignorelist, path):
-            tests['tabs'] = self._check_tabs
-        if not self._match(self.whitespaces_ignorelist, path):
-            tests['whitespaces'] = self._check_trailing_whitespaces
-        if not self._match(self.longlines_ignorelist, path):
-            tests['longlines'] = self._check_longline
-        if not self._match(self.dosbreaks_ignorelist, path):
-            tests['doslinebreaks'] = self._check_dosbreaks
-        return tests
-
-    def _check_tabs(self, line):
-        """ Checks if given line contains tabs """
-        if '\t' in line:
-            return True
-        else:
-            return False
-
-    def _check_dosbreaks(self, line):
-        if '\r' in line:
-            return True
-        else:
-            return False
-
-    def _check_trailing_whitespaces(self, line):
-        """ Checks if line has trailing whitespaces.
-            This is copied from text_checker plugin """
-        import re
-        trailing_ws_match = re.match(r'^((.*?)([\t ]*))(\r?\n)?$', line)
-        if trailing_ws_match:
-            return bool(trailing_ws_match.group(3))
-        else:
-            return False
-
-    def _check_longline(self, line):
-        """ Checks if given line is longer than 80 chars """
-        if len(line) > self.longline_length:
-            return True
-        else:
-            return False
-
-    def _check_file(self, file_id, path):
-        """ Apply tests for given file """
-
-        # Get the lines of the file in a list
-        file_lines = self.new_tree.get_file(file_id).readlines()
-
-        # Log problems and line numbers
-        problems = {'tabs' : [], 'whitespaces' : [], 'longlines' : [], 
'newline' : [], 'doslinebreaks' : []}
-
-        # Dont check empty files or files on ignorelist
-        if len(file_lines) > 0 and not self._match(self.newlines_ignorelist, 
path):
-            # Check for newline at eof
-            if not file_lines[-1].endswith('\n'):
-                problems['newline'] = [len(file_lines)]
-
-        # Get further tests to perform
-        tests = self._get_tests(path)
-
-        # If there are no further tests to perform, return
-        if len(tests.keys()) == 0:
-            return problems
-
-        # Keep track of line numbers where errors occur
-        counter = 0
-
-         # Perform tests on every line of every and log problems
-        for line in file_lines:
-            counter += 1
-            for type, test in tests.iteritems():
-                if test(line):
-                    problems[type].append(counter)
-
-        # Return problems
-        return problems
-
-    def check(self):
-        """ Checks for each touched file in this patch if it is whitelisted,
-            and if not, if it contains tabs."""
-
-        # If this is an uncommit, there's nothing to be done
-        if (self.new_revno - self.old_revno) < 0:
-            return
-
-        # Lock the trees
-        self.old_tree.lock_read()
-        self.new_tree.lock_read()
-
-        try:
-            # Check all modified files in new working tree
-            problems = {}
-            iterator = self.new_tree.iter_changes(self.old_tree)
-            for (file_id, paths, changed_content, versioned, parent, name, 
kind, executable) in iterator:
-                # paths contains two paths: the old one (index 0) and the new 
path (index 1) of the modified file
-                # they are different if file was added, renamed or removed
-                NEW_PATH = 1
-                # Omit checking for files that are being removed
-                if not paths[NEW_PATH] is None:
-                    problems[paths[NEW_PATH]] = self._check_file(file_id, 
paths[NEW_PATH])
-
-            # Construct possible error message
-            fmt_string = ""
-            arglist = []
-            for file, problems_of_file in problems.iteritems():
-                # display filename only once
-                disply_filename = True
-                for type, linenumbers in problems_of_file.iteritems():
-                    if len(linenumbers) > 0:
-                        if disply_filename:
-                            fmt_string += "%12s failed check\t(type = %-15s in 
lines %s \n"
-                            arglist += [file, type+")", str(linenumbers)]
-                            disply_filename = False
-                        else:
-                            fmt_string += "\t\t\t\t(type = %-15s in lines %s 
\n"
-                            arglist += [type+")", str(linenumbers)]
-
-            # Report the errors if there were any
-            errormessage = str(fmt_string % tuple(arglist))
-            if errormessage != "":
-                # Append the old log-message
-                errormessage += "\nYou entered the following log-message:\n"
-                if not self.revision.message:
-                    errormessage += "  (no log message available)\n"
-                else:
-                    errormessage += self.revision.message.rstrip('\r\n')
-                errormessage += "\n\n"
-
-                # Report the errors
-                raise errors.TipChangeRejected("\nThe commit was rejected, 
because there were errors.\n" + errormessage)
-
-        finally:
-            self.old_tree.unlock()
-            self.new_tree.unlock()

=== removed directory 'tools/bzrhooks/tagchecker'
=== removed file 'tools/bzrhooks/tagchecker/__init__.py'
--- tools/bzrhooks/tagchecker/__init__.py       2010-06-01 16:02:05 +0000
+++ tools/bzrhooks/tagchecker/__init__.py       1970-01-01 00:00:00 +0000
@@ -1,97 +0,0 @@
-# Copyright (C) 2005, 2006, 2007 Canonical Ltd
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-"""Checking commit messages for whitelisted tags.
-
-The plugin will reject all commits whose commit messages don't contain the 
following pattern:
-"[taglist]", where tags is a comma-separated whitelist of tags.
-The allowed tags are specified in option `tagchecker_whitelist` in the 
branch.conf of every branch,
-the tagchecker should control.
-e.g. add line
-    tagchecker_whitelist = tag1,tag2,...,tagn
-to the branch.conf.
-
-To install this plug in system wide copy it into the plugins directory
-of the bzrlib. You can find out the directory of the bzrlib by executing
-    `` bzr version | grep bzrlib ``
-This should be something like
-    `` /usr/lib/python2.6/dist-packages/bzrlib ``
-Then you put the plugin into
-    `` /usr/lib/python2.6/dist-packages/bzrlib/plugins/tagchecker ``
-That's all.
-
-You can check the installation by executing
-    `` bzr plugins ``
-(tagchecker plugin should be displayed with a short message)
-or
-    `` bzr hooks ``
-(pre_change_branch_tip should have an entry from tagchecker now)
-"""
-
-
-if __name__ != 'bzrlib.plugins.tagchecker':
-    raise ImportError('The email plugin must be installed as'
-                      ' bzrlib.plugins.tagchecker not %s'
-                      % __name__)
-
-
-# These three are used during import: No point lazy_importing them.
-from bzrlib import errors
-from bzrlib.branch import Branch
-from bzrlib.lazy_import import lazy_import
-
-# lazy_import emailer so that it doesn't get loaded if it isn't used
-lazy_import(globals(), """\
-from bzrlib.plugins.tagchecker import tagchecker as _tagchecker
-""")
-
-def pre_change_branch_tip_hook(params):
-    """This hook will be called on the server's side before a change."""
-    # (branch, old_revno, new_revno, old_revid, new_revid)
-    _tagchecker.TagChecker(params).check()
-
-def install_hook(bzr_hook, callback, name):
-    """Install the given hook with the given name """
-    if bzr_hook in Branch.hooks:
-        install_named_hook = getattr(Branch.hooks, 'install_named_hook', None)
-        if install_named_hook is not None:
-            install_named_hook(bzr_hook, callback, name)
-        else:
-            Branch.hooks.install_hook(bzr_hook, callback)
-            if getattr(Branch.hooks, 'name_hook', None) is not None:
-                Branch.hooks.name_hook(callback, name)
-    else:
-        raise errors.BzrError("Bazaar version does not support " + bzr_hook + 
" hooks.")
-
-# Install all hooks here
-def install_hooks():
-    """Install pre_change_branch_tip hook """
-    install_hook('pre_change_branch_tip', pre_change_branch_tip_hook, 'bzr 
tagchecker')
-
-def test_suite():
-    return
-
-
-# setup the email plugin with > 0.15 hooks.
-try:
-    install_hooks()
-    use_legacy = False
-except AttributeError:
-    # bzr < 0.15 - no Branch.hooks
-    use_legacy = True
-except errors.UnknownHook:
-    # bzr 0.15 dev before post_commit was added
-    use_legacy = True

=== removed file 'tools/bzrhooks/tagchecker/tagchecker.py'
--- tools/bzrhooks/tagchecker/tagchecker.py     2010-06-01 16:02:05 +0000
+++ tools/bzrhooks/tagchecker/tagchecker.py     1970-01-01 00:00:00 +0000
@@ -1,91 +0,0 @@
-# Copyright (C) 2005, 2006, 2007 Canonical Ltd
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-from bzrlib import errors
-
-class TagChecker(object):
-
-    def __init__(self, params, local_branch=None):
-        """ The only thing we need is the revision and the config"""
-
-        self.config = params.branch.get_config()
-
-        if (local_branch is not None and 
local_branch.repository.has_revision(self.new_rev_id)):
-            repository = local_branch.repository
-        else:
-            repository = params.branch.repository
-
-        self.revision = repository.get_revision(params.new_revid)
-
-    def _errormessage(self, tag_list, reason):
-        res = ""
-        if reason == "notagfound":
-            res += "\n" \
-                "Commit was rejected because the commit-message did not 
contain any tag \n" \
-                "The commit-message should contain at least one tag from the 
following list: \n"
-
-            # Append list of allowed tags
-            for tag in tag_list:
-                res += "    - " + tag + "\n"
-
-        elif reason == "wrongformat":
-            res += "\n" \
-                "Commit was rejected because tags were not given in the right 
format \n" \
-                "Tags should appear immediately at the beginning of the commit 
message enclosed in brackets.\n" \
-                "F.e. [tag1, tag2, tag3, ... ] logsummary ... logmessage...\n" 
\
-
-        # Append the old log-message
-        res += "\n" \
-            "You entered the following log-message:\n"
-        if not self.revision.message:
-            res += "  (no log message found)\n"
-        else:
-            res += self.revision.message.rstrip('\r\n')
-            res += "\n\n"
-
-        return res
-
-    def check(self):
-        """ Check if the commit message begins with at
-            least one tag from a whitelist, given by
-            commit_notification_tags option. """
-
-        # This is the tag white list
-        # Each commit message should begin with at least one of those tags
-        # tag_white_list = ["test","bugfix","docu"]
-        tag_white_list = self.config.get_user_option('tagchecker_whitelist')
-
-        # No tag checking...
-        if tag_white_list is None:
-            return
-
-        # Get commit message
-        message = self.revision.message
-
-        # We assume that tags are enclosed in brackets
-        tags_start = message.find('[')
-        tags_end = message.find(']')
-        if tags_start != 0 or tags_end == -1:
-            raise errors.TipChangeRejected(self._errormessage(tag_white_list, 
"wrongformat"))
-
-        # Check for each tag from the white list if it appears in the message 
tag area
-        # and return on first match
-        for tag in tag_white_list:
-            if message.find(tag, tags_start, tags_end) != -1:
-                return
-
-        # No match found
-        raise errors.TipChangeRejected(self._errormessage(tag_white_list, 
"notagfound"))

=== modified file 'tools/hipconf.c'
--- tools/hipconf.c     2010-07-04 17:54:18 +0000
+++ tools/hipconf.c     2010-10-29 12:05:42 +0000
@@ -1,8 +1,5 @@
-/** @file
- * This file defines the main function of the command line tool 'hipconf'.
- *
- * @author  Miika Komu <miika_iki.fi>
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -24,6 +21,13 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file
+ * This file defines the main function of the command line tool 'hipconf'.
+ *
+ * @author  Miika Komu <miika_iki.fi>
  * @bug     makefile compiles prefix of debug messages wrong for hipconf in
  *          "make all"
  */
@@ -48,9 +52,8 @@
     hip_set_logtype(LOGTYPE_STDERR);
     hip_set_logfmt(LOGFMT_SHORT);
 
-    /* Hipconf displays nothing if debug level is set to none in
-     * /etc/hip/hipd_config because also hipconf reads the config
-     * file. This re-enables the the logging for hipconf. */
+    /* Reenable logging for hipconf. Since hipconf reads the hipd configuration
+     * file, hipconf will be silent if debug level is set to none there. */
     hip_set_logdebug(LOGDEBUG_ALL);
 
     HIP_IFEL(hip_do_hipconf(argc, argv, 0), -2,

=== renamed file 'tools/hipdnsproxy/hipdnsproxy' => 
'tools/hipdnsproxy/hipdnsproxy.in'
--- tools/hipdnsproxy/hipdnsproxy       2010-05-16 17:58:14 +0000
+++ tools/hipdnsproxy/hipdnsproxy.in    2010-10-29 12:51:08 +0000
@@ -1,6 +1,6 @@
 #! /usr/bin/env python
 
-# HIP name look-up daemon for /etc/hip/hosts and DNS and Bamboo servers
+# HIP name look-up daemon for HIPL hosts file and DNS servers
 #
 # Usage: Basic usage without any command line options.
 #        See getopt() for the options.
@@ -17,11 +17,10 @@
 # - Test name resolution with following methods:
 #   - Non-HIP records
 #   - Hostname to HIT resolution
-#     - HITs and LSIs from /etc/hip/hosts
+#     - HITs and LSIs from @sysconfdir@/hosts
 #     - On-the-fly generated LSI; HIT either from from DNS or hosts
 #     - HI records from DNS
-#     - HITs from Bamboo via hipd
-#   - PTR records: maps HITs to hostnames from /etc/hip/hosts
+#   - PTR records: maps HITs to hostnames from @sysconfdir@/hosts
 #
 # Actions to resolv.conf files and dnsproxy hooking:
 # - Dnsmasq=on, revolvconf=on: only hooks dnsmasq
@@ -287,7 +286,7 @@
         os.system('killall --quiet hipconf 2>/dev/null')
 
 class Global:
-    default_hiphosts = "/etc/hip/hosts"
+    default_hiphosts = "@sysconfdir@/hosts"
     default_hosts = "/etc/hosts"
     re_nameserver = re.compile(r'nameserver\s+(\S+)$')
     def __init__(gp):

=== modified file 'tools/hipdnsproxy/hosts.py'
--- tools/hipdnsproxy/hosts.py  2010-04-28 15:47:49 +0000
+++ tools/hipdnsproxy/hosts.py  2010-11-08 14:06:09 +0000
@@ -164,7 +164,7 @@
                     aaaa_hit[n] = (addr, 0)
                 elif self.str_is_ipv6(addr):
                     aaaa[n] = (addr, 0)
-                else:
+                elif not self.str_is_lsi(addr):
                     a[n] = (addr, 0)
         self.a = a
         self.aaaa = aaaa

=== modified file 'tools/hipl_autobuild.sh'
--- tools/hipl_autobuild.sh     2010-06-02 11:35:16 +0000
+++ tools/hipl_autobuild.sh     2010-11-05 08:46:43 +0000
@@ -1,8 +1,19 @@
 #!/bin/sh
-# HIPL autobuild script for periodic compilation tests.
+# HIPL autobuild script for periodic compilation and quality tests.
 # The name of the branch to test needs to be passed as the first parameter.
 #
-# This script relies on the following directory layout:
+# The script is suitable to be run from cron in order to provide basic
+# continuous integration. Errors encountered during operation are logged
+# to a text file and sent off by email. To receive these notifications,
+# set the HIPL_NOTIFICATION_EMAIL environment variable to a suitable value.
+#
+# No full checkout of HIPL sources is done. In order to greatly speed up
+# testing multiple branches, lightweight checkouts are used. The shared
+# repository from which the checkouts are extracted is expected to have
+# been updated before this script is run.
+#
+# This script relies on the following home directory layout of the user
+# running it:
 # - $HOME/src/hipl/           - location for HIPL shared repository
 # - $HOME/src/hipl/<branch>   - location for HIPL <branch> to be tested
 # - $HOME/tmp/autobuild/hipl/ - temporary build directory
@@ -14,12 +25,8 @@
 #           directory.
 # RATIONALE I was not sure where the VERSION info added by Miika should have 
been
 #           extracted from in the first place.
-# TODO      Which are the system dependencies for this script?
 # TODO      What should cron-jobs typically look like and why?
 #           - Rene (26.05.2010)
-#
-# If the HIPL_NOTIFICATION_EMAIL environment variable is set to a suitable 
value
-# for the user running this script, then email will be sent in case of failure.
 
 if test "$1" = ""; then
     echo "usage: $0 <branch_name>"
@@ -79,10 +86,10 @@
 }
 
 # Check if 'make dist' contains all files that are under version control.
-check_dist()
+check_dist_tarball()
 {
-    # TODO I'm not a sed user, please explain
-    find -L . | sed -e 1d -e 's:./::' -e '/\.bzr/d' -e '/autom4te.cache/d' -e 
'/file_list_checkout/d' -e '/tools\/bzrhooks/d' |
+    # Remove autogenerated, Bazaar-related and similar files from the list.
+    find -L . | sed -e 1d -e 's:./::' -e '/\.bzr/d' -e '/autom4te.cache/d' -e 
'/file_list_checkout/d' |
         sort > file_list_checkout
     ./configure && make dist
     tar -tzf hipl-*.tar.gz |
@@ -91,20 +98,27 @@
     run_program diff -u file_list_checkout file_list_tarball
 }
 
+# There should be no Doxygen warnings.
+check_doxygen()
+{
+    make doxygen > /dev/null 2> doxygen_stderr
+    touch empty
+    run_program diff -u empty doxygen_stderr
+}
+
 compile()
 {
-    # TODO add short description - what is tested in which directory?
+    # Run compile and install tests for a certain configuration, in-tree.
     CONFIGURATION="--prefix=$(pwd)/local_install $@"
     run_program "./configure" $CONFIGURATION &&
-        run_program "make -j17" &&
-        run_program "make -j17 checkheaders" &&
+        run_program "make -j"                &&
+        run_program "make -j checkheaders"   &&
         run_program "make install"
 }
 
 # only run the autobuilder for newer revisions than the last one checked
 test $BRANCH_REVISION = $AUTOBUILD_REVISION && exit 0
 
-# TODO why is the repo up-to-date?
 bzr checkout -q --lightweight $BRANCH_URL $CHECKOUT_DIR || cleanup 1
 
 cd "$CHECKOUT_DIR" || cleanup 1
@@ -113,19 +127,33 @@
 run_program autoreconf --install
 
 CONFIGURATION="distribution tarball completeness"
-check_dist
+check_dist_tarball
+
+CONFIGURATION="Doxygen documentation"
+check_doxygen
 
 # Compile HIPL in different configurations
 # vanilla configuration
 compile
-# TODO what does this do compared to check_dist?
-run_program "make -j17 distcheck"
+
+# internal autoconf tests, bootstrap the dist tarball, build out-of-tree, etc
+run_program "make -j distcheck"
+
+# run unit tests (this check needs to run after HIPL has been compiled)
+run_program "make -j check"
 
 # PISA configuration
 compile --enable-firewall --disable-rvs --disable-opportunistic 
--disable-profiling --enable-debug --enable-midauth --disable-performance 
--disable-demo
 
-# Alternative path to vanilla
-compile --enable-firewall --disable-rvs --disable-opportunistic 
--enable-profiling --disable-debug --enable-midauth --enable-performance 
--enable-demo
+# Max compile coverage configuration
+FEATURES_ALL="--enable-firewall --enable-rvs --enable-opportunistic 
--enable-profiling --disable-debug --enable-midauth --enable-performance 
--enable-demo"
+compile $FEATURES_ALL
+
+# Max compile coverage configuration without optimization
+compile $FEATURES_ALL CFLAGS="-O0"
+
+# Max compile coverage configuration with full optimization
+compile $FEATURES_ALL CFLAGS="-O3"
 
 # Without modules
 compile --with-nomodules=heartbeat,update,heartbeat_update
@@ -136,8 +164,8 @@
 cd $OPENWRT_DIR || cleanup 1
 run_program "rm -rf package/hipl"
 run_program "cp -r $CHECKOUT_DIR/packaging/openwrt/package package/hipl"
-run_program "make -j17 package/hipl-clean V=99"
-run_program "make -j17 package/hipl-install V=99"
+run_program "make -j package/hipl/clean V=99"
+run_program "make -j package/hipl/install V=99"
 
 
 # Crosscompile HIPL in a scratchbox environment.
@@ -145,12 +173,12 @@
 # scratchbox complains if USER is missing from the environment
 export USER=$LOGNAME
 
-CONFIGURATION="Scratchbox ARM crosscompile"
-cd $SCRATCHBOX_HOME || cleanup 1
+#CONFIGURATION="Scratchbox ARM crosscompile"
+#cd $SCRATCHBOX_HOME || cleanup 1
 # clean-up previous run and get fresh sources for compilation (in host env)
-run_program "rm -rf hipl-[0-9.]* hipl_*.changes hipl_*.deb"
-run_program "tar -xzf $CHECKOUT_DIR/hipl-[0-9.]*.tar.gz"
+#run_program "rm -rf hipl-[0-9.]* hipl_*.changes hipl_*.deb"
+#run_program "tar -xzf $CHECKOUT_DIR/hipl-[0-9.]*.tar.gz"
 # perform debian packaging (in maemo sdk env)
-run_program "$SCRATCHBOX_DIR/login -d hipl-[0-9.]* dpkg-buildpackage 
-rfakeroot -b"
+#run_program "$SCRATCHBOX_DIR/login -d hipl-[0-9.]* dpkg-buildpackage 
-rfakeroot -b"
 
 cleanup 0

=== removed file 'tools/mailer.sh'
--- tools/mailer.sh     2010-08-26 14:12:39 +0000
+++ tools/mailer.sh     1970-01-01 00:00:00 +0000
@@ -1,62 +0,0 @@
-#!/bin/sh
-#
-# Mailer script that notifies about commits to a BZR repo
-#
-# Copyright (c) 2010 Mircea Gherzan <mgherzan@xxxxxxxxx>
-
-# path to the BZR repository
-REPO=/home/$USER/src/hipl
-# path to the file containing the last processed revision
-LASTREV=/tmp/mailer_lastrev.txt
-# buffer used to build the body of the e-mail
-MAILBUF=/tmp/mailer_buffer.txt 
-
-# mailing coordinates
-SENDTO=hipl-core@xxxxxxxxxxxxxxxxxxx
-REPLYTO=hipl-core@xxxxxxxxxxxxxxxxxxx
-
-#####################################################################
-
-if [ ! -e $LASTREV ] ; then
-       echo File with the last revno does not exist!
-       echo Please create $LASTREV
-       exit 1
-fi
-
-read lastrev < $LASTREV
-
-# from now on, working in the BZR repo 
-cd $REPO
-
-# update the repo to get the last revision
-bzr up
-
-# get the HEAD revision (the last one)
-head=$(bzr revno)
-
-# lastrev was already processed, so incrementing it
-lastrev=$(($lastrev + 1))
-
-for rev in $(seq $lastrev $head) ; do 
-
-       committer=$(bzr log -r $rev | head -3 | tail -1 | sed -e "s/committer: 
//g")
-
-       branch=$(bzr log -r $rev | head -4 | tail -1 | sed -e "s/branch nick: 
//g")
-
-       firstline=$(bzr log -r $rev | head -7 | tail -1 | sed -e "s/^ *//")
-
-       subject="[$branch] $rev: $firstline"
-
-       # create the body of the e-mail
-       > $MAILBUF
-       bzr log -r $rev | tail -n +7 >> $MAILBUF
-       echo "" >> $MAILBUF
-       bzr diff -c $rev >> $MAILBUF
-
-       # send the e-mail
-       mailx -s "$subject" -Sfrom="$committer" -Sreplyto=$REPLYTO $SENDTO < 
$MAILBUF
-done
-
-echo $head > $LASTREV 
-
-exit 0

=== modified file 'tools/maintainer/sync-all'
--- tools/maintainer/sync-all   2010-05-26 21:37:57 +0000
+++ tools/maintainer/sync-all   2010-10-24 19:32:18 +0000
@@ -1,7 +1,7 @@
 #!/bin/sh -xv
 
 HOSTS="
-halko.pc.infrahip.net
+garadar.infrahip.net
 netherstorm.infrahip.net
 terokkar.infrahip.net
 shadowmoon.infrahip.net
@@ -27,11 +27,10 @@
 # unconfigured:
 # ubuntu lucid 32-bit allerian
 # ubuntu lucid 64-bit cenarion 64-bit
-# ubuntu lucid 64-bit garadar
 #
 # configured:
 # Ubuntu lucid 32-bit terokkar.infrahip.net
-# Ubuntu lucid 64-bit halko.pc.infrahip.net (real host)
+# ubuntu lucid 64-bit garadar
 # f12-i386            netherstorm.infrahip.net
 # F12-x86_64          shadowmoon.infrahip.net
 # CentOS-5.4 i386     hellfire.infrahip.net
@@ -42,6 +41,7 @@
 # disabled:
 # F10-x86_64          nagrand.infrahip.net
 # FC11-i386           hipserver (real host)
+# Ubuntu lucid 64-bit halko.pc.infrahip.net (real host)
 
 if test $# != 0
 then

=== modified file 'tools/maintainer/update-html-code'
--- tools/maintainer/update-html-code   2010-04-01 17:10:37 +0000
+++ tools/maintainer/update-html-code   2010-10-29 11:37:09 +0000
@@ -1,6 +1,5 @@
 #!/bin/sh
 
-REVISION=main
 TMP_DIR=~/.hipl.doxygen.tmp.dir
 WWW_DIR=/var/www/infrahip/html/hipl
 OUTPUT_DIR=$WWW_DIR/doxygen

=== renamed file 'tools/nsupdate.pl' => 'tools/nsupdate.pl.in'
--- tools/nsupdate.pl   2010-03-05 02:21:54 +0000
+++ tools/nsupdate.pl.in        2010-10-29 12:51:08 +0000
@@ -17,10 +17,10 @@
 ###########################################################
 use strict;
 
-my $CONFIG_PATH = "/etc/hip/nsupdate.conf";
+my $CONFIG_PATH = "@sysconfdir@/nsupdate.conf";
 
 ##########################################################
-# default values, please change in /etc/hip/nsupdate.conf
+# default values, please change in above configuration file
 our $DEBUG = 0;
 our $LOG_FACILITY = 'local6';
 our $HIT_TO_IP_ZONE = 'hit-to-ip.infrahip.net.';

=== modified file 'tools/pisacert.c'
--- tools/pisacert.c    2010-08-19 09:32:20 +0000
+++ tools/pisacert.c    2010-10-15 15:29:14 +0000
@@ -1,6 +1,5 @@
-/** @file
- *
- * Copyright (c) 2010 Aalto University) and RWTH Aachen University.
+/*
+ * Copyright (c) 2010 Aalto University and RWTH Aachen University.
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -22,7 +21,10 @@
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
- *
+ */
+
+/**
+ * @file
  * Generate a SPKI certificate for use with PISA.
  *
  * @author Thomas Jansen <mithi@xxxxxxxxx>

Other related posts:

  • » [hipl-dev] [Branch ~rene-hummen/hipl/ipsec_esp] Rev 4940: merged to lp:hipl revision 5140 - noreply