sm.c (dcd6c9b595c8714aa29d3f604f8aeba289f06c41) | sm.c (c7e2c1a542dadacc23cd62771be7147d28e1cb0f) |
---|---|
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 --- 1190 unchanged lines hidden (view full) --- 1199 if (bonding_enabed){ 1200 1201 // lookup device based on IRK 1202 if (setup->sm_key_distribution_received_set & SM_KEYDIST_FLAG_IDENTITY_INFORMATION){ 1203 int i; 1204 for (i=0; i < le_device_db_max_count(); i++){ 1205 sm_key_t irk; 1206 bd_addr_t address; | 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 --- 1190 unchanged lines hidden (view full) --- 1199 if (bonding_enabed){ 1200 1201 // lookup device based on IRK 1202 if (setup->sm_key_distribution_received_set & SM_KEYDIST_FLAG_IDENTITY_INFORMATION){ 1203 int i; 1204 for (i=0; i < le_device_db_max_count(); i++){ 1205 sm_key_t irk; 1206 bd_addr_t address; |
1207 int address_type; | 1207 int address_type = BD_ADDR_TYPE_UNKNOWN; |
1208 le_device_db_info(i, &address_type, address, irk); | 1208 le_device_db_info(i, &address_type, address, irk); |
1209 if (memcmp(irk, setup->sm_peer_irk, 16) == 0){ 1210 log_info("sm: device found for IRK, updating"); 1211 le_db_index = i; 1212 break; 1213 } | 1209 // check if valid entry retrieved 1210 if (address_type == BD_ADDR_TYPE_UNKNOWN) continue; 1211 // compare IRK 1212 if (memcmp(irk, setup->sm_peer_irk, 16) != 0) continue; 1213 1214 log_info("sm: device found for IRK, updating"); 1215 le_db_index = i; 1216 break; |
1214 } | 1217 } |
1218 } else { 1219 // assert IRK is set to zero 1220 memset(setup->sm_peer_irk, 0, 16); |
|
1215 } 1216 1217 // if not found, lookup via public address if possible 1218 log_info("sm peer addr type %u, peer addres %s", setup->sm_peer_addr_type, bd_addr_to_str(setup->sm_peer_address)); 1219 if (le_db_index < 0 && setup->sm_peer_addr_type == BD_ADDR_TYPE_LE_PUBLIC){ 1220 int i; 1221 for (i=0; i < le_device_db_max_count(); i++){ 1222 bd_addr_t address; --- 2847 unchanged lines hidden --- | 1221 } 1222 1223 // if not found, lookup via public address if possible 1224 log_info("sm peer addr type %u, peer addres %s", setup->sm_peer_addr_type, bd_addr_to_str(setup->sm_peer_address)); 1225 if (le_db_index < 0 && setup->sm_peer_addr_type == BD_ADDR_TYPE_LE_PUBLIC){ 1226 int i; 1227 for (i=0; i < le_device_db_max_count(); i++){ 1228 bd_addr_t address; --- 2847 unchanged lines hidden --- |