af-packet: fix problem introduced in recent commit

Logic of patch 98e4a14f6d59fe8928fd6e2af3d9c3e8b42d00bf was correct
but implementation is wrong because TP_STATUS_KERNEL is equal to
zero and thus can not be evaluated in a binary operation. This patch
updates the logic by doing two tests.

Reported-by: Alessandro Guido
Bug 980: fix HTTP memory cleanup at shutdown

Buffers in per thread HTTP header, client body and server body storage
would be freed based on the usage indicator instead of the size
indicator.

As the usage indicator (e.g. hsbd_buffers_list_len) could be reset
while leaving the memory untouched for later reuse, the free function
would not iterate over all memory blocks.

Removed DrMemory suppressions as well.

Bug #980.
util-device: use safe tailq foreach

The loop is freeing elements so we need to use the safe version
of TIALQ_FOREACH.

This fixes a valgrind error:

 Thread 1 Suricata-Main:
 Invalid read of size 8
    at 0x8E129C: LiveDeviceListClean (util-device.c:167)
    by 0x89B742: main (suricata.c:2284)
  Address 0x8382988 is 24 bytes inside a block of size 40 free'd
    at 0x4C2A70C: free (vg_replace_malloc.c:468)
    by 0x8E1297: LiveDeviceListClean (util-device.c:179)
    by 0x89B742: main (suricata.c:2284)
app-layer-ssl: code cleanup

Don't alloc a void ptr and then cast in every operation. Instead,
alloc a SSLState ptr and only case to void on returning the ptr.
app-layer-ssl: style fixes

Coding style fixes for TLS handshake parser.
app-layer-ssl: fix unusual memory leak

In some cases the TLS state pointers to subject and issuerdn could
be overwritten by a new memory allocation, causing us to loose
track of the old.

This has been observed in the case of improper VLAN handling, where
it was suspected that multiple unrelated TLS streams were mangled
together.
Bug 1083 and 1084: add valgrind suppressions

Add suppressions as these are minor issues and likely not bugs in
Suricata.
dns: fix dns configure code

Yaml layout changed. DNS had to be updated to retrievel value
for dns flood from the correct location in the config tree.
dns: add memcap options

Add per state and global memcap option parsing.
dns: make DNSTransactionAlloc static
dns: add memcap checking

Add memuse tracking and memcap checking to the DNS parsers. Memuse
is tracked globally and per flow (state).

Memcaps are also checked per flow and globally before memory allocs
are done.
Pass ThreadVars ptr to various thread init funcs

To be able to register counters from AppLayerGetCtxThread, the
ThreadVars pointer needs to be available in it and thus in it's
callers:

- AppLayerGetCtxThread
- DecodeThreadVarsAlloc
- StreamTcpReassembleInitThreadCtx
app-layer: update UDP entry function

Update AppLayerHandleUdp to take the ThreadVars pointer as an
argument in prepraration of handling counters in this function.
dns: register counters

Register dns memory counters.
Keep track of memcap reached conditions, and increment counters for
those.
dns: update counters

This patch updates the DNS counters from the main AppLayer entry
functions. Due to the limited scope of AppLayerThreadCtx some of
the logic had to be implemented in app-layer.c, where it doesn't
belong.
dns: add event for when memcap is reached

Raise event if state-memcap is reached for a flow.
App-layer proto detect cleanups

Remove unnecessay inlining.
Rename functions with wrong naming scheme. E.g. AllocAppLayer.. instead
of AppLayer..Alloc.
Use AppProto instead of uint16_t.
Convert u16 ipproto cases to u8.
Coverity 1153935: fix confusing sizeof
app-layer proto detect: optimization

Don't use FlowGetProtoMapping at runtime, use f->protomap instead.
Add safety check to make sure its value is within range, as it's
used to index an array.

Update unittests to initialized flows (somewhat).
detect: use pflow pointer

Use pflow pointer in SigMatchSignatures consistently. Also, when
needing access to the ipproto, use p->proto, not p->flow->proto.