[GitHub] [mynewt-nimble] utzig commented on pull request #1241: host: l2cap: check connection parameters in ble_l2cap_sig_update_req_rx
utzig commented on PR #1241: URL: https://github.com/apache/mynewt-nimble/pull/1241#issuecomment-1104323849 ## Style check summary ### Our coding style is [here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md) apps/bttester/src/gap.c ```diff @@ -48,8 +48,8 @@ #define REJECT_SUPERVISION_TIMEOUT 0x0C80 const uint8_t irk[16] = { -0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, -0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, +0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, +0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, }; static uint8_t oob[16]; @@ -685,1091 +702,1132 @@ * If the resolution procedure fails, then the Host shall disconnect * with the error code "Authentication failure" [...] */ -static void periph_privacy(struct ble_gap_conn_desc desc) +static void +periph_privacy(struct ble_gap_conn_desc desc) { #if !MYNEWT_VAL(BTTESTER_PRIVACY_MODE) -return; +return; #endif -int count; - -SYS_LOG_DBG(""); - -ble_store_util_count(BLE_STORE_OBJ_TYPE_PEER_SEC, &count); -if (count > 0 && BLE_ADDR_IS_RPA(&desc.peer_id_addr)) { -SYS_LOG_DBG("Authentication failure, disconnecting"); -ble_gap_terminate(desc.conn_handle, BLE_ERR_AUTH_FAIL); -} -} - -static void device_connected_ev_send(struct os_event *ev) -{ -struct ble_gap_conn_desc desc; -int rc; - -SYS_LOG_DBG(""); - -rc = gap_conn_find_by_addr((ble_addr_t *)&connected_ev, &desc); -if (rc) { -tester_rsp(BTP_SERVICE_ID_GAP, GAP_EV_DEVICE_CONNECTED, - CONTROLLER_INDEX, BTP_STATUS_FAILED); -return; -} - -tester_send(BTP_SERVICE_ID_GAP, GAP_EV_DEVICE_CONNECTED, -CONTROLLER_INDEX, (uint8_t *) &connected_ev, -sizeof(connected_ev)); - -periph_privacy(desc); -} - -static void le_connected(uint16_t conn_handle, int status) -{ -struct ble_gap_conn_desc desc; -ble_addr_t *addr; -int rc; - -SYS_LOG_DBG(""); - -if (status != 0) { -return; -} - -rc = ble_gap_conn_find(conn_handle, &desc); -if (rc) { -return; -} - -peer_id_addr = desc.peer_id_addr; -peer_ota_addr = desc.peer_ota_addr; - -addr = &desc.peer_id_addr; - -memcpy(connected_ev.address, addr->val, sizeof(connected_ev.address)); -connected_ev.address_type = addr->type; -connected_ev.conn_itvl = desc.conn_itvl; -connected_ev.conn_latency = desc.conn_latency; -connected_ev.supervision_timeout = desc.supervision_timeout; +int count; + +SYS_LOG_DBG(""); + +ble_store_util_count(BLE_STORE_OBJ_TYPE_PEER_SEC, &count); +if (count > 0 && BLE_ADDR_IS_RPA(&desc.peer_id_addr)) { +SYS_LOG_DBG("Authentication failure, disconnecting"); +ble_gap_terminate(desc.conn_handle, BLE_ERR_AUTH_FAIL); +} +} + +static void +device_connected_ev_send(struct os_event *ev) +{ +struct ble_gap_conn_desc desc; +int rc; + +SYS_LOG_DBG(""); + +rc = gap_conn_find_by_addr((ble_addr_t *)&connected_ev, &desc); +if (rc) { +tester_rsp(BTP_SERVICE_ID_GAP, GAP_EV_DEVICE_CONNECTED, + CONTROLLER_INDEX, BTP_STATUS_FAILED); +return; +} + +tester_send(BTP_SERVICE_ID_GAP, GAP_EV_DEVICE_CONNECTED, +CONTROLLER_INDEX, (uint8_t *) &connected_ev, +sizeof(connected_ev)); + +periph_privacy(desc); +} + +static void +le_connected(uint16_t conn_handle, int status) +{ +struct ble_gap_conn_desc desc; +ble_addr_t *addr; +int rc; + +SYS_LOG_DBG(""); + +if (status != 0) { +return; +} + +rc = ble_gap_conn_find(conn_handle, &desc); +if (rc) { +return; +} + +peer_id_addr = desc.peer_id_addr; +peer_ota_addr = desc.peer_ota_addr; + +addr = &desc.peer_id_addr; + +memcpy(connected_ev.address, addr->val, sizeof(connected_ev.address)); +connected_ev.address_type = addr->type; +connected_ev.conn_itvl = desc.conn_itvl; +connected_ev.conn_latency = desc.conn_latency; +connected_ev.supervision_timeout = desc.supervision_timeout; #if MYNEWT_VAL(BTTESTER_CONN_RETRY) -os_callout_reset(&connected_ev_co, - os_time_ms_to_ticks32( - CONNECTED_EV_DELAY_MS(desc.conn_itvl))); +os_callout_reset(&connected_ev_co, + os_time_ms_to_ticks32( + CONNECTED_EV_DELAY_MS(desc.conn_itvl))); #else -tester_send(BTP_SERVI
[GitHub] [mynewt-nimble] utzig commented on pull request #1241: host: l2cap: check connection parameters in ble_l2cap_sig_update_req_rx
utzig commented on PR #1241: URL: https://github.com/apache/mynewt-nimble/pull/1241#issuecomment-1104922110 ## Style check summary ### Our coding style is [here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md) apps/bttester/src/gap.c ```diff @@ -48,8 +48,8 @@ #define REJECT_SUPERVISION_TIMEOUT 0x0C80 const uint8_t irk[16] = { -0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, -0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, +0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, +0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, }; static uint8_t oob[16]; @@ -685,1091 +702,1132 @@ * If the resolution procedure fails, then the Host shall disconnect * with the error code "Authentication failure" [...] */ -static void periph_privacy(struct ble_gap_conn_desc desc) +static void +periph_privacy(struct ble_gap_conn_desc desc) { #if !MYNEWT_VAL(BTTESTER_PRIVACY_MODE) -return; +return; #endif -int count; - -SYS_LOG_DBG(""); - -ble_store_util_count(BLE_STORE_OBJ_TYPE_PEER_SEC, &count); -if (count > 0 && BLE_ADDR_IS_RPA(&desc.peer_id_addr)) { -SYS_LOG_DBG("Authentication failure, disconnecting"); -ble_gap_terminate(desc.conn_handle, BLE_ERR_AUTH_FAIL); -} -} - -static void device_connected_ev_send(struct os_event *ev) -{ -struct ble_gap_conn_desc desc; -int rc; - -SYS_LOG_DBG(""); - -rc = gap_conn_find_by_addr((ble_addr_t *)&connected_ev, &desc); -if (rc) { -tester_rsp(BTP_SERVICE_ID_GAP, GAP_EV_DEVICE_CONNECTED, - CONTROLLER_INDEX, BTP_STATUS_FAILED); -return; -} - -tester_send(BTP_SERVICE_ID_GAP, GAP_EV_DEVICE_CONNECTED, -CONTROLLER_INDEX, (uint8_t *) &connected_ev, -sizeof(connected_ev)); - -periph_privacy(desc); -} - -static void le_connected(uint16_t conn_handle, int status) -{ -struct ble_gap_conn_desc desc; -ble_addr_t *addr; -int rc; - -SYS_LOG_DBG(""); - -if (status != 0) { -return; -} - -rc = ble_gap_conn_find(conn_handle, &desc); -if (rc) { -return; -} - -peer_id_addr = desc.peer_id_addr; -peer_ota_addr = desc.peer_ota_addr; - -addr = &desc.peer_id_addr; - -memcpy(connected_ev.address, addr->val, sizeof(connected_ev.address)); -connected_ev.address_type = addr->type; -connected_ev.conn_itvl = desc.conn_itvl; -connected_ev.conn_latency = desc.conn_latency; -connected_ev.supervision_timeout = desc.supervision_timeout; +int count; + +SYS_LOG_DBG(""); + +ble_store_util_count(BLE_STORE_OBJ_TYPE_PEER_SEC, &count); +if (count > 0 && BLE_ADDR_IS_RPA(&desc.peer_id_addr)) { +SYS_LOG_DBG("Authentication failure, disconnecting"); +ble_gap_terminate(desc.conn_handle, BLE_ERR_AUTH_FAIL); +} +} + +static void +device_connected_ev_send(struct os_event *ev) +{ +struct ble_gap_conn_desc desc; +int rc; + +SYS_LOG_DBG(""); + +rc = gap_conn_find_by_addr((ble_addr_t *)&connected_ev, &desc); +if (rc) { +tester_rsp(BTP_SERVICE_ID_GAP, GAP_EV_DEVICE_CONNECTED, + CONTROLLER_INDEX, BTP_STATUS_FAILED); +return; +} + +tester_send(BTP_SERVICE_ID_GAP, GAP_EV_DEVICE_CONNECTED, +CONTROLLER_INDEX, (uint8_t *) &connected_ev, +sizeof(connected_ev)); + +periph_privacy(desc); +} + +static void +le_connected(uint16_t conn_handle, int status) +{ +struct ble_gap_conn_desc desc; +ble_addr_t *addr; +int rc; + +SYS_LOG_DBG(""); + +if (status != 0) { +return; +} + +rc = ble_gap_conn_find(conn_handle, &desc); +if (rc) { +return; +} + +peer_id_addr = desc.peer_id_addr; +peer_ota_addr = desc.peer_ota_addr; + +addr = &desc.peer_id_addr; + +memcpy(connected_ev.address, addr->val, sizeof(connected_ev.address)); +connected_ev.address_type = addr->type; +connected_ev.conn_itvl = desc.conn_itvl; +connected_ev.conn_latency = desc.conn_latency; +connected_ev.supervision_timeout = desc.supervision_timeout; #if MYNEWT_VAL(BTTESTER_CONN_RETRY) -os_callout_reset(&connected_ev_co, - os_time_ms_to_ticks32( - CONNECTED_EV_DELAY_MS(desc.conn_itvl))); +os_callout_reset(&connected_ev_co, + os_time_ms_to_ticks32( + CONNECTED_EV_DELAY_MS(desc.conn_itvl))); #else -tester_send(BTP_SERVI