agent: Fix segmentation fault

This patch fixes a segmentation fault when the agent leaves the bus
and there is a request passkey pending.

bluetoothd[3137]: src/agent.c:agent_exited() Agent exited without
calling Unregister
==3137== Invalid read of size 8
==3137==    at 0x4489E7: device_get_adapter (device.c:2197)
==3137==    by 0x448C69: passkey_cb (device.c:2757)
==3137==    by 0x43FA47: agent_free (agent.c:168)
==3137==    by 0x40A738: service_filter (watch.c:477)
==3137==    by 0x40A450: message_filter (watch.c:527)
==3137==    by 0x516451B: dbus_connection_dispatch (in
/usr/lib64/libdbus-1.so.3.5.8)
==3137==    by 0x409387: message_dispatch (mainloop.c:76)
==3137==    by 0x4E7986A: g_timeout_dispatch (in
/usr/lib64/libglib-2.0.so.0.3000.2)
==3137==    by 0x4E78091: g_main_context_dispatch (in
/usr/lib64/libglib-2.0.so.0.3000.2)
==3137==    by 0x4E78887: g_main_context_iterate.clone.6 (in
/usr/lib64/libglib-2.0.so.0.3000.2)
==3137==    by 0x4E78DD9: g_main_loop_run (in
/usr/lib64/libglib-2.0.so.0.3000.2)
==3137==    by 0x431AA6: main (main.c:542)
==3137==  Address 0xe818247c89102594 is not stack'd, malloc'd or
(recently) free'd
GATT: Rename Characteristic Configuration constants

This patch renames the constants related to Client Characteristic
Configuration bit field to use a proper name since it is related to
GATT instead of ATT.
GATT: Move GATT assigned numbers to GATT header
gattrib: Fix a request/response command deadlock

New requests and responses are never sent if a request was sent and the
response for it hasn't been received yet. As a result, if both end
points send requests at the same time, a deadlock could occur. This
could happen, for instance, if the client sends a read request and the
server sends an indication before responding to the read request.

Fix this by introducing an additional queue for responses. Responses may
be sent while there's still a pending request/indication.
core: Remove unneeded textfile header include
GATT: Avoid unneeded discover transaction

This patch fix unneeded discover characteristics transaction when the
last characteristic declaration contains the handle number equals to the
end handle of the primary service.
attrib-server: allow SDP records for secondary GATT services

It seems this is the correct way to discover such services that work
over BR/EDR (according to section 4.4 in the GATT specification).
Remove compatibility check for DBUS_TYPE_UNIX_FD

Since commit c89b589a586e97ad875fbdd1d41f03979157ebb0, D-Bus >= 1.4.0 is
required. This version already contains Unix FD passing support,
therefore code that checks for DBUS_TYPE_UNIX_FD definition is
unnecessary.
hciattach: Add basic Three-wire UART support
GATT: Don't modify L2CAP MTU after exchange MTU

Changing L2CAP MTU after GATT Exchange MTU procedure doesn't
make sense. L2CAP channel configuration parameters should be
set before connection establishment. Thus, these bt_io_set calls
will always fail.
Attrib: Don't set BT_IO_OPT_OMTU in LE connection

This patch removes BT_IO_OPT_OMTU parameter from bt_io_connect in
case of LE connection.

The ATT_MTU is negotiate at ATT protocol through the GATT Exchange
MTU procedure.
Attrib: Fix gatt_connect for BR/EDR

Use BT_IO_OPT_IMTU instead of BT_IO_OPT_OMTU in bt_io_connect.
Attrib: Remove workaround in gatt_connect

This workaround is not necessary anymore since setsockopt is now
checking for minimum MTU.
GAttrib: Fix g_attrib_new

attrib->buf should be allocated according to ATT_MTU value. Over
BR/EDR, ATT_MTU should be set to the L2CAP MTU negotiated during
L2CAP configuration phase. Over LE, ATT_MTU is 23 octets.
Fix attrib_channel_attach
Fix mtu_exchange