Add byte order helper functions

The NASDAQ ITCH 4.1 protocol, for example, needs byte order conversion
helpers.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
Use <endian.h> for byte order helpers

Also add missing helper functions.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
FAST: Byte Vector support introduced

Signed-off-by: Marat Stanichenko <mstanichenko@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
FAST: Default operator should occupy a bit inside the PMAP

Signed-off-by: Marat Stanichenko <mstanichenko@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
FAST: session configuration structure introduced

This patch introduces per-session configuration
data structure which is to be used to initialize
FAST session properly (see fast_session_new()).
The principles are the same as with FIX protocol.

At the moment the following settings are supported:

* Preamble - some venues put a few bytes in front of
each FAST encoded message. These bytes do not obey to
FAST encoding rules and present auxiliary information
(e.g. MsgSeqNum). At the moment libtrading do not use
such a preamble but can skip a particular number of bytes
before it starts to decode a message.

* Reset - some venues make a decoder to reset dictionary
explicitly (e.g. they incorporate a particular bytes
combination into the stream  - 0xC0 0xF8) but some venues
assume that a decoder should reset dictionary without any
notification (e.g. if unreliable UDP protocol is used to
disseminate the data). In the latter case we raise a flag
within the FAST session data structure to indicate that
reset should be performed without any notification
received.

* Source specific multicast - some venues use source
specific multicast (IP_ADD_SOURCE_MEMBERSHIP). Libtrading
should support it also

Signed-off-by: Marat Stanichenko <mstanichenko@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
FAST: Increase the maximum number of sequence elements supported

It's not unusual to receive an order book updates of the depth 50.
In such a case the Snapshot message would contain of 100 sequence
elements (50 for bids and 50 for ask).

Signed-off-by: Marat Stanichenko <mstanichenko@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
FAST: Delta operator for ascii strings implemented

This implementation is naive and might be optimized later

Signed-off-by: Marat Stanichenko <mstanichenko@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
FAST: preserve pmap_bit whenever data are not fully received

pmap_bit is a bit checked whenever FAST field is decoded.
If buffer does not contain enough data to decode the whole
field we should preserver the previous pmap_bit value and
wait until necessary bytes will be received.

Signed-off-by: Marat Stanichenko <mstanichenko@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
FAST: use glib hash table implementation to store FAST fields

hsearch_r() API is not available on Darwin (a.k.a. Mac OS X)
so this is causing a build regression. Since glib is supported
on all relevant platforms, let use that library for the moment.

Reported-by: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Marat Stanichenko <mstanichenko@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>