hci.c (64472d52af09d19f0f9153f6ed370a13e23ceafb) | hci.c (decc01a8dc6f97c744522ec8141a050e07aed30e) |
---|---|
1/* 2 * Copyright (C) 2009 by Matthias Ringwald 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 --- 257 unchanged lines hidden (view full) --- 266 log_err( "ACL Cont Fragment but no first fragment for handle 0x%02x\n", con_handle); 267 return; 268 } 269 270 // append fragment payload (header already stored) 271 memcpy(&conn->acl_recombination_buffer[conn->acl_recombination_pos], &packet[4], acl_length ); 272 conn->acl_recombination_pos += acl_length; 273 | 1/* 2 * Copyright (C) 2009 by Matthias Ringwald 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 --- 257 unchanged lines hidden (view full) --- 266 log_err( "ACL Cont Fragment but no first fragment for handle 0x%02x\n", con_handle); 267 return; 268 } 269 270 // append fragment payload (header already stored) 271 memcpy(&conn->acl_recombination_buffer[conn->acl_recombination_pos], &packet[4], acl_length ); 272 conn->acl_recombination_pos += acl_length; 273 |
274 // log_err( "ACL Cont Fragment: acl_len %u, combined_len %u, l2cap_len %u\n", 275 // acl_length, connection->acl_recombination_pos, connection->acl_recombination_length); | 274 // log_err( "ACL Cont Fragment: acl_len %u, combined_len %u, l2cap_len %u\n", acl_length, 275 // conn->acl_recombination_pos, conn->acl_recombination_length); |
276 277 // forward complete L2CAP packet if complete. 278 if (conn->acl_recombination_pos >= conn->acl_recombination_length + 4 + 4){ // pos already incl. ACL header 279 280 hci_stack.packet_handler(HCI_ACL_DATA_PACKET, conn->acl_recombination_buffer, conn->acl_recombination_pos); 281 // reset recombination buffer 282 conn->acl_recombination_length = 0; 283 conn->acl_recombination_pos = 0; 284 } 285 break; 286 287 case 0x02: { // first fragment 288 289 // sanity check 290 if (conn->acl_recombination_pos) { 291 log_err( "ACL First Fragment but data in buffer for handle 0x%02x\n", con_handle); 292 return; 293 } | 276 277 // forward complete L2CAP packet if complete. 278 if (conn->acl_recombination_pos >= conn->acl_recombination_length + 4 + 4){ // pos already incl. ACL header 279 280 hci_stack.packet_handler(HCI_ACL_DATA_PACKET, conn->acl_recombination_buffer, conn->acl_recombination_pos); 281 // reset recombination buffer 282 conn->acl_recombination_length = 0; 283 conn->acl_recombination_pos = 0; 284 } 285 break; 286 287 case 0x02: { // first fragment 288 289 // sanity check 290 if (conn->acl_recombination_pos) { 291 log_err( "ACL First Fragment but data in buffer for handle 0x%02x\n", con_handle); 292 return; 293 } |
294 | 294 |
295 // peek into L2CAP packet! 296 uint16_t l2cap_length = READ_L2CAP_LENGTH( packet ); 297 | 295 // peek into L2CAP packet! 296 uint16_t l2cap_length = READ_L2CAP_LENGTH( packet ); 297 |
298 // log_err( "ACL First Fragment: acl_len %u, l2cap_len %u\n", acl_length, l2cap_length); 299 |
|
298 // compare fragment size to L2CAP packet size 299 if (acl_length >= l2cap_length + 4){ 300 301 // forward fragment as L2CAP packet 302 hci_stack.packet_handler(HCI_ACL_DATA_PACKET, packet, acl_length + 4); 303 304 } else { 305 // store first fragment and tweak acl length for complete package 306 memcpy(conn->acl_recombination_buffer, packet, acl_length + 4); 307 conn->acl_recombination_pos = acl_length + 4; 308 conn->acl_recombination_length = l2cap_length; | 300 // compare fragment size to L2CAP packet size 301 if (acl_length >= l2cap_length + 4){ 302 303 // forward fragment as L2CAP packet 304 hci_stack.packet_handler(HCI_ACL_DATA_PACKET, packet, acl_length + 4); 305 306 } else { 307 // store first fragment and tweak acl length for complete package 308 memcpy(conn->acl_recombination_buffer, packet, acl_length + 4); 309 conn->acl_recombination_pos = acl_length + 4; 310 conn->acl_recombination_length = l2cap_length; |
309 bt_store_16(conn->acl_recombination_buffer, 2, acl_length +4); 310 // log_err( "ACL First Fragment: acl_len %u, l2cap_len %u\n", acl_length, l2cap_length); | 311 bt_store_16(conn->acl_recombination_buffer, 2, l2cap_length +4); |
311 } 312 break; 313 314 } 315 default: 316 log_err( "hci.c: acl_handler called with invalid packet boundary flags %u\n", acl_flags & 0x03); 317 return; 318 } --- 874 unchanged lines hidden --- | 312 } 313 break; 314 315 } 316 default: 317 log_err( "hci.c: acl_handler called with invalid packet boundary flags %u\n", acl_flags & 0x03); 318 return; 319 } --- 874 unchanged lines hidden --- |