l2cap.c (9700d53b492bfdb05045e7b72da3d5a72977682e) l2cap.c (7f1690cf27ca04545945f16bd57a2ec52ce35927)
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 890 unchanged lines hidden (view full) ---

899}
900#endif
901
902#ifdef ENABLE_CLASSIC
903void l2cap_emit_channel_opened(l2cap_channel_t *channel, uint8_t status) {
904 log_info("L2CAP_EVENT_CHANNEL_OPENED status 0x%x addr %s handle 0x%x psm 0x%x local_cid 0x%x remote_cid 0x%x local_mtu %u, remote_mtu %u, flush_timeout %u",
905 status, bd_addr_to_str(channel->address), channel->con_handle, channel->psm,
906 channel->local_cid, channel->remote_cid, channel->local_mtu, channel->remote_mtu, channel->flush_timeout);
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 890 unchanged lines hidden (view full) ---

899}
900#endif
901
902#ifdef ENABLE_CLASSIC
903void l2cap_emit_channel_opened(l2cap_channel_t *channel, uint8_t status) {
904 log_info("L2CAP_EVENT_CHANNEL_OPENED status 0x%x addr %s handle 0x%x psm 0x%x local_cid 0x%x remote_cid 0x%x local_mtu %u, remote_mtu %u, flush_timeout %u",
905 status, bd_addr_to_str(channel->address), channel->con_handle, channel->psm,
906 channel->local_cid, channel->remote_cid, channel->local_mtu, channel->remote_mtu, channel->flush_timeout);
907#ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE
908 log_info("ERTM mode %u, fcs enabled %u", channel->mode, channel->fcs_option);
909#endif
910 uint8_t event[24];
907 uint8_t event[26];
911 event[0] = L2CAP_EVENT_CHANNEL_OPENED;
912 event[1] = sizeof(event) - 2;
913 event[2] = status;
914 reverse_bd_addr(channel->address, &event[3]);
915 little_endian_store_16(event, 9, channel->con_handle);
916 little_endian_store_16(event, 11, channel->psm);
917 little_endian_store_16(event, 13, channel->local_cid);
918 little_endian_store_16(event, 15, channel->remote_cid);
919 little_endian_store_16(event, 17, channel->local_mtu);
920 little_endian_store_16(event, 19, channel->remote_mtu);
921 little_endian_store_16(event, 21, channel->flush_timeout);
922 event[23] = channel->state_var & L2CAP_CHANNEL_STATE_VAR_INCOMING ? 1 : 0;
908 event[0] = L2CAP_EVENT_CHANNEL_OPENED;
909 event[1] = sizeof(event) - 2;
910 event[2] = status;
911 reverse_bd_addr(channel->address, &event[3]);
912 little_endian_store_16(event, 9, channel->con_handle);
913 little_endian_store_16(event, 11, channel->psm);
914 little_endian_store_16(event, 13, channel->local_cid);
915 little_endian_store_16(event, 15, channel->remote_cid);
916 little_endian_store_16(event, 17, channel->local_mtu);
917 little_endian_store_16(event, 19, channel->remote_mtu);
918 little_endian_store_16(event, 21, channel->flush_timeout);
919 event[23] = channel->state_var & L2CAP_CHANNEL_STATE_VAR_INCOMING ? 1 : 0;
920#ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE
921 log_info("ERTM mode %u, fcs enabled %u", channel->mode, channel->fcs_option);
922 event[24] = channel->mode;
923 event[25] = channel->fcs_option;
924
925#else
926 event[24] = L2CAP_CHANNEL_MODE_BASIC;
927 event[25] = 0;
928#endif
923 hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
924 l2cap_dispatch_to_channel(channel, HCI_EVENT_PACKET, event, sizeof(event));
925}
926
927static void l2cap_emit_channel_closed(l2cap_channel_t *channel) {
928 log_info("L2CAP_EVENT_CHANNEL_CLOSED local_cid 0x%x", channel->local_cid);
929 l2cap_emit_simple_event_with_cid(channel, L2CAP_EVENT_CHANNEL_CLOSED);
930}

--- 2915 unchanged lines hidden ---
929 hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
930 l2cap_dispatch_to_channel(channel, HCI_EVENT_PACKET, event, sizeof(event));
931}
932
933static void l2cap_emit_channel_closed(l2cap_channel_t *channel) {
934 log_info("L2CAP_EVENT_CHANNEL_CLOSED local_cid 0x%x", channel->local_cid);
935 l2cap_emit_simple_event_with_cid(channel, L2CAP_EVENT_CHANNEL_CLOSED);
936}

--- 2915 unchanged lines hidden ---