unit: Add test for gatt_exchange_mtu()

The new unit/test-gatt.c file will contain tests for GATT API
implemented in attrib/gatt.{c,h}.
attrib: Rename gatt_find_info() to gatt_discover_char_desc()

The old name referred to the underlying ATT PDU (Find Information
Request and Find Information Response) and not to the actual GATT
procedure (Discover All Characteristic Descriptors).
attrib: Modify gatt_cb_t signature

The boolean return value will have the same semantics as GLib watches:
returning "true" will keep the GATT procedure going; returning "false"
will interrupt it (either due to an error or because the desired
information was found.)

This "early interruption" of GATT procedures is allowed by the spec and
avoids unnecessary data transfers, specially on large attribute
databases and when using small MTU values.

Other changes are to use standard C types instead of GLib ones (which
are unnecessary here) and move the "status" parameter to the first
position, so it is consistent with other callbacks.
unit: Add test for gatt_discover_primary()
core: Refactor memory allocation for GATT service discovery

Prior to implementing partial primary service discovery, it is necessary
to move allocation of struct included_search, so the list of found
services (search->services) can be created incrementally.

Note that this list is also used later to collect (secondary) included
services and only then the full list of found services is used for
registering new services and detecting added/removed profiles.
core: Do not pass around memory allocated internally by GATT API

Instead, do a "deep copy" of the list of GATT services. While this
generates extra heap allocations, it also allows proper cleanup in case
of ATT or link errors. In other words, memory allocated by GATT API will
be freed by GATT API after callback returns.
attrib: Run callback with the partial result of service discovery

Callbacks should check for status equal to ATT_ECODE_ATTR_NOT_FOUND to
ensure that the service discovery has finished.
core: Only do Find Included Services after receiving all GATT services

Now that the primary service discovery callback is called on partial
discovery (instead of waiting for the entire discovery procedure to
finish), the included services discovery should wait until the full list
of services is found.

This is necessary because the logic for detecting added/removed services
depends on the full list of discovered services.
attrib: Allow dec_read_resp() to just check if PDU is valid

If a NULL "value" parameter is given, only check whether PDU is valid,
without copying attribute value to a buffer.
attrib: Avoid passing raw ATT PDU to gatt_read_char() callback

Instead, pass the attribute value/length. This simplifies error
handling and reduces memory copying.
attrib: Do not use Write Command in gatt_write_char()

Previously, if no callback was given to gatt_write_char(), it was
assumed that a "Write Without Response" (which uses Write Command)
should be used instead of Write Request.

This "shortcut" is unnecessary (there is gatt_write_cmd() for the
situations where Write Without Response is required) and just duplicates
code.

This commit also fixes the few places where gatt_write_cmd() should be
used.
attrib: Fix coding style in prepare_write_cb()
attrib: Simplify prepare_write()

All parameters can be retrieved from struct write_long_data fields,
therefore there is no need to pass them separately.
attrib: Avoid passing raw ATT PDU to gatt_write_char() callback

Instead, pass only status and user data. The ATT PDU validation is now
done internally by GATT API.
attrib: Avoid passing raw PDU to gatt_discover_char_desc() callback

By centralizing the PDU parsing and validation internally to GATT API,
the callbacks become simpler.
gatttool: Remove unused code

Since commit 6a3a89774c6738df4d5b77636c4ce747b7497ae9 the code
removed here has no sense.
gatt: Avoid passing raw PDU to read characteristic by UUID

By centralizing the PDU parsing and validation internally to GATT API,
the callbacks become simpler.
unit: Add test for gatt_discover_char_desc()