TLS: add detection for malicious heartbeats (AKA heartbleed)

The OpenSSL implementation of RFC 6520 (Heartbeat extension) does not
check the payload length correctly, resulting in a copy of at most 64k
of memory from the server (ref: CVE-2014-0160).
This patch adds support for decoding heartbeat messages (if not
encrypted), and checking several parts (type, length and padding).
When an anomaly is detected, a TLS event is raised.
output: clean file desc at exit.

This is a beginning of implementation for bug #1660:
 https://redmine.openinfosecfoundation.org/issues/1160

This patch adds a cleaning function for each logger of new type
(packet, tx and file). These functions are called in RunModeShutDown().

The state of this patch is that it is crashing suricata when sending
pcap to analyse:
 - At first pcap if tx and file cleaning function are called
 - At second pcap if only packet cleaning function is called

The cause in first case is unknown. In second case this is due to
the necessity of cleaning the list of logger registered to a logging
type.
unified2: fix memory leak at shutdown

Module didn't properly free output context at shutdown. Led to a leak
in Unix Socket mode.
output: add Disable funcs to mirror Enable

For the loggers that we allow only one instance for: tls, ssh, drop, we
track active loggers through Output*Enable functions. Add Disable
functions to mirror this. They are to be called from the shutdown funcs
those loggers use.
drop loggers: call disable func

Call OutputDropLoggerDisable() on cleanup.
log-tls: run Disable at shutdown

Call OutputTlsLoggerDisable at cleanup.
alert-json: fix cleanup

Call specialized clean up function when running as a sub-module.
dns-json: fix cleanup

Use specialized cleanup function for sub-module case. Freeing the
LogFileCtx is not the responsibility of a sub-module.
file-json: cleanup at shutdown

Fix a memory leak at shutdown. Module didn't have a cleanup function.
http-json: add missing cleanup functions

Add cleanup functions.
ssh-json: add clean up functions

Add clean up functions for the SSH json logger.
eve-log: fix mem leak at shutdown

Make sure we free all memory in the shutdown function.
drop-json: fix cleanup

Use proper function for sub-module cleanup. LogFileCtx is not managed
by the sub-module, so don't clean it.
tls-json: add cleanup function

Properly clean up output context when shutting down.
output api: complete shutdown functions

Add missing function for Filedata API. Clean up list in all functions.
output-api: cleanup handling

Add output 'free list' that contains all the output ctx' that need
cleanup at shutdown. It differs from the runmode output list in that
it will also contain a 'parent' for the submodules that share the
context of it's parent.
Fix 2 compiler warnings

FreeBSD 10 32-bit with clang 3.3:

log-tlslog.c:172:14: error: format specifies type 'long' but the argument has type 'time_t' (aka 'int') [-Werror,-Wformat]
             p->ts.tv_sec,
             ^~~~~~~~~~~~
1 error generated.

detect-engine-payload.c:508:27: warning: format specifies type 'long' but the argument has type 'time_t' (aka 'int') [-Wformat]
    printf("%ld.%06ld\n", tv_diff.tv_sec, (long int)tv_diff.tv_usec);
            ~~~           ^~~~~~~~~~~~~~
            %d
1 warning generated.
util-ioctl: only get MTU when iface name is set

This patch fixes a warning message when suricata is started without
giving an interface name on the command line. The code was trying
to get the MTU even if pcap_dev was not set.
af-packet: fix error handling

Only exit from synchronization loop on poll error and not in case
of a timeout.
detect: modify AMATCH locking

This is an intrusive change. This patch modifies the way AMATCH
inspection uses locking.

So far, each keyword did it's own locking. This lead to a situation
where a 'alstate' pointer was passed around that was not always
protected by a lock.

This patch moves the locking to the Stateful detection functions.