static void btif_test_discovery_result_cback(UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_DISC_RES *p_data) { char str_buf[50]; UNUSED(conn_id); LOG_DEBUG(LOG_TAG, "------ GATT Discovery result %-22s -------", disc_name[disc_type]); LOG_DEBUG(LOG_TAG, " Attribute handle: 0x%04x (%d)", p_data->handle, p_data->handle); if (disc_type != GATT_DISC_CHAR_DSCPT) { LOG_DEBUG(LOG_TAG, " Attribute type: %s", format_uuid(p_data->type, str_buf)); } switch (disc_type) { case GATT_DISC_SRVC_ALL: LOG_DEBUG(LOG_TAG, " Handle range: 0x%04x ~ 0x%04x (%d ~ %d)", p_data->handle, p_data->value.group_value.e_handle, p_data->handle, p_data->value.group_value.e_handle); LOG_DEBUG(LOG_TAG, " Service UUID: %s", format_uuid(p_data->value.group_value.service_type, str_buf)); break; case GATT_DISC_SRVC_BY_UUID: LOG_DEBUG(LOG_TAG, " Handle range: 0x%04x ~ 0x%04x (%d ~ %d)", p_data->handle, p_data->value.handle, p_data->handle, p_data->value.handle); break; case GATT_DISC_INC_SRVC: LOG_DEBUG(LOG_TAG, " Handle range: 0x%04x ~ 0x%04x (%d ~ %d)", p_data->value.incl_service.s_handle, p_data->value.incl_service.e_handle, p_data->value.incl_service.s_handle, p_data->value.incl_service.e_handle); LOG_DEBUG(LOG_TAG, " Service UUID: %s", format_uuid(p_data->value.incl_service.service_type, str_buf)); break; case GATT_DISC_CHAR: LOG_DEBUG(LOG_TAG, " Properties: 0x%02x", p_data->value.dclr_value.char_prop); LOG_DEBUG(LOG_TAG, " Characteristic UUID: %s", format_uuid(p_data->value.dclr_value.char_uuid, str_buf)); break; case GATT_DISC_CHAR_DSCPT: LOG_DEBUG(LOG_TAG, " Descriptor UUID: %s", format_uuid(p_data->type, str_buf)); break; } LOG_DEBUG(LOG_TAG, "-----------------------------------------------------------"); }
void check_linuxswap(exec_options *eo, file_state *fs, off_t offset) { offset -= 7*512; // TODO: 4k block specific uint8_t uuid[16]; FS_READ(fs, uuid, offset+0x40C, 16); uint32_t page_count = read_le_uint32(fs, offset+0x404); page_count += 1; off_t fs_size = page_count * 4096; // TODO: 4k block specific switch ( eo->part_format_type ) { default: printf("linux swap v1 at offset %s\n", format_offset(eo, offset)); printf(" filesystem size %llu 512-blocks = %llu bytes ~= %s\n", (long long unsigned int) fs_size/512, (long long unsigned int) fs_size, format_humansize(eo, fs_size)); printf(" uuid %s\n", format_uuid(eo, uuid)); if ( eo->verbose ) printf(" page count %lu\n", (long unsigned) page_count); printf("\n"); } if ( !fs->skip_active ) { fs->skip_active = true; fs->skip_to = offset+fs_size; } }
void detect_reiser(SECTION *section, int level) { unsigned char *buf; int i, at, newformat; int offsets[3] = { 8, 64, -1 }; char s[256]; u8 blockcount; u4 blocksize; for (i = 0; offsets[i] >= 0; i++) { at = offsets[i]; if (get_buffer(section, at * 1024, 1024, (void **)&buf) < 1024) continue; /* check signature */ if (memcmp(buf + 52, "ReIsErFs", 8) == 0) { print_line(level, "ReiserFS file system (old 3.5 format, standard journal, starts at %d KiB)", at); newformat = 0; } else if (memcmp(buf + 52, "ReIsEr2Fs", 9) == 0) { print_line(level, "ReiserFS file system (new 3.6 format, standard journal, starts at %d KiB)", at); newformat = 1; } else if (memcmp(buf + 52, "ReIsEr3Fs", 9) == 0) { newformat = get_le_short(buf + 72); if (newformat == 0) { print_line(level, "ReiserFS file system (old 3.5 format, non-standard journal, starts at %d KiB)", at); } else if (newformat == 2) { print_line(level, "ReiserFS file system (new 3.6 format, non-standard journal, starts at %d KiB)", at); newformat = 1; } else { print_line(level, "ReiserFS file system (v3 magic, but unknown version %d, starts at %d KiB)", newformat, at); continue; } } else continue; /* get data */ blockcount = get_le_long(buf); blocksize = get_le_short(buf + 44); /* for new format only: hashtype = get_le_long(buf + 64); */ /* get label */ get_string(buf + 100, 16, s); if (s[0]) print_line(level + 1, "Volume name \"%s\"", s); format_uuid(buf + 84, s); print_line(level + 1, "UUID %s", s); /* print size */ format_blocky_size(s, blockcount, blocksize, "blocks", NULL); print_line(level + 1, "Volume size %s", s); /* TODO: print hash code */ } }
void detect_linux_raid(SECTION *section, int level) { unsigned char *buf; u8 pos; int rlevel, nr_disks, raid_disks, spare; u1 uuid[16]; char s[256]; /* don't do this if: * - the size is unknown (0) * - the size is too small for the calculation * - it is inefficient to read from the end of the source */ if (section->size < 65536 || section->source->sequential) return; /* get RAID superblock from the end of the device */ pos = (section->size & ~65535) - 65536; if (get_buffer(section, pos, 4096, (void **)&buf) < 4096) return; /* signature */ if (get_le_long(buf) != 0xa92b4efc) return; print_line(level, "Linux RAID disk, version %lu.%lu.%lu", get_le_long(buf + 4), get_le_long(buf + 8), get_le_long(buf + 12)); /* get some data */ rlevel = (int)(long)get_le_long(buf + 28); /* is signed, actually */ nr_disks = get_le_long(buf + 36); raid_disks = get_le_long(buf + 40); spare = nr_disks - raid_disks; /* find the name for the personality in the table */ if (rlevel < -4 || rlevel > 5 || levels[rlevel+4] == NULL) { print_line(level + 1, "Unknown RAID level %d using %d regular %d spare disks", rlevel, raid_disks, spare); } else { print_line(level + 1, "%s set using %d regular %d spare disks", levels[rlevel+4], raid_disks, spare); } /* get the UUID */ memcpy(uuid, buf + 5*4, 4); memcpy(uuid + 4, buf + 13*4, 3*4); format_uuid(uuid, s); print_line(level + 1, "RAID set UUID %s", s); }
void detect_reiser4(SECTION *section, int level) { unsigned char *buf; char s[256]; int layout_id; char layout_name[64]; u4 blocksize; u8 blockcount; if (get_buffer(section, 16 * 4096, 1024, (void **)&buf) < 1024) return; /* check signature */ if (memcmp(buf, "ReIsEr4", 7) != 0) return; /* get data from master superblock */ layout_id = get_le_short(buf + 16); blocksize = get_le_short(buf + 18); if (layout_id == 0) strcpy(layout_name, "4.0 layout"); else sprintf(layout_name, "Unknown layout with ID %d", layout_id); format_size(s, blocksize); print_line(level, "Reiser4 file system (%s, block size %s)", layout_name, s); /* get label and UUID */ get_string(buf + 36, 16, s); if (s[0]) print_line(level + 1, "Volume name \"%s\"", s); format_uuid(buf + 20, s); print_line(level + 1, "UUID %s", s); if (layout_id == 0) { /* read 4.0 superblock */ if (get_buffer(section, 17 * 4096, 1024, (void **)&buf) < 1024) return; if (memcmp(buf + 52, "ReIsEr40FoRmAt", 14) != 0) { print_line(level + 1, "Superblock for 4.0 format missing"); return; } blockcount = get_le_quad(buf); format_blocky_size(s, blockcount, blocksize, "blocks", NULL); print_line(level + 1, "Volume size %s", s); } }
void detect_btrfs(SECTION *section, int level) { unsigned char *buf; char s[258]; if (get_buffer(section, 64 * 1024, 1024, (void **)&buf) < 1024) return; if (memcmp(buf + 64, "_BHRfS_M", 8) == 0) { print_line(level, "Btrfs file system"); get_string(buf + 299, 256, s); if (s[0]) print_line(level + 1, "Volume name \"%s\"", s); format_uuid(buf + 32, s); print_line(level + 1, "UUID %s", s); format_size(s, get_le_quad(buf + 0x70)); print_line(level + 1, "Volume size %s", s); } }
/* * Generates a uuid based on version 1 format. * Returns 0 on success and -1 on failure. */ static int uuid_create(struct uuid *uuid) { uuid_time_t timestamp; uuid_node_t system_node; int ret, non_unique = 0; /* * Get the system MAC address and/or cache it */ if (node_init) { bcopy(&node_id_cache, &system_node, sizeof (uuid_node_t)); } else { gen_ethernet_address(&system_node); bcopy(&system_node, &node_id_cache, sizeof (uuid_node_t)); node_init = 1; } /* * Access the state file, mmap it and initialize the shared lock. * file_type tells us whether we had access to the state file or * created a temporary one. */ if (map_state() == -1) return (-1); /* * Acquire the lock */ for (;;) { if ((ret = mutex_lock(&data->lock)) == 0) break; else switch (ret) { case EOWNERDEAD: revalidate_data(&system_node); (void) mutex_consistent(&data->lock); (void) mutex_unlock(&data->lock); break; case ENOTRECOVERABLE: return (ret); } } /* State file is either new or is temporary, get a random clock seq */ if (data->state.clock == 0) { data->state.clock = get_random(); non_unique++; } if (memcmp(&system_node, &data->state.node, sizeof (uuid_node_t)) != 0) data->state.clock++; get_current_time(×tamp); /* * If timestamp is not set or is not in the past, bump * data->state.clock */ if ((data->state.ts == 0) || (data->state.ts >= timestamp)) { data->state.clock++; data->state.ts = timestamp; } if (non_unique) system_node.nodeID[0] |= 0x80; /* Stuff fields into the UUID struct */ format_uuid(uuid, data->state.clock, timestamp, system_node); (void) mutex_unlock(&data->lock); return (0); }
void detect_ext234(SECTION *section, int level) { unsigned char *buf; char s[256]; int fslevel, is_journal, is_dev; u4 blocksize; u8 blockcount; if (get_buffer(section, 1024, 1024, (void **)&buf) < 1024) return; if (get_le_short(buf + 56) == 0xEF53) { fslevel = 2; is_journal = 0; is_dev = 0; /* Ext3/4 external journal: INCOMPAT feature JOURNAL_DEV */ if (get_le_long(buf + 96) & 0x0008) { is_journal = 1; fslevel = 3; /* at least ext3, ext2 has no journalling */ } /* Ext3/4 COMPAT feature: HAS_JOURNAL */ if (get_le_long(buf + 92) & 0x0004) fslevel = 3; /* Ext4 INCOMPAT features: EXTENTS, 64BIT, FLEX_BG */ //if (get_le_long(buf + 96) & 0x02C0) // fslevel = 4; /* Ext4 RO_COMPAT features: HUGE_FILE, GDT_CSUM, DIR_NLINK, EXTRA_ISIZE */ if (get_le_long(buf + 100) & 0x0078) fslevel = 4; /* Ext4 sets min_extra_isize even on external journals */ //if (get_le_short(buf + 348) >= 0x1c) // fslevel = 4; /* Ext4dev TEST_FILESYS flag */ //if (get_le_long(buf + 352) & 0x0004) // is_dev = 1; print_line(level, "Ext%d%s %s", fslevel, is_dev ? "dev" : "", is_journal ? "external journal" : "file system"); get_string(buf + 120, 16, s); if (s[0]) print_line(level + 1, "Volume name \"%s\"", s); format_uuid(buf + 104, s); print_line(level + 1, "UUID %s", s); get_string(buf + 136, 64, s); if (s[0]) print_line(level + 1, "Last mounted at \"%s\"", s); blocksize = 1024 << get_le_long(buf + 24); blockcount = get_le_long(buf + 4); format_blocky_size(s, blockcount, blocksize, "blocks", NULL); print_line(level + 1, "Volume size %s", s); /* 76 4 s_rev_level */ /* 62 2 s_minor_rev_level */ /* 72 4 s_creator_os */ /* 92 3x4 s_feature_compat, s_feature_incompat, s_feature_ro_compat */ } }
bt_status_t btif_gattc_test_command_impl(uint16_t command, btgatt_test_params_t* params) { switch(command) { case 0x01: /* Enable */ { LOG_DEBUG(LOG_TAG, "%s: ENABLE - enable=%d", __FUNCTION__, params->u1); if (params->u1) { tBT_UUID app_uuid = {LEN_UUID_128,{0xAE}}; test_cb.gatt_if = GATT_Register(&app_uuid, &btif_test_callbacks); GATT_StartIf(test_cb.gatt_if); } else { GATT_Deregister(test_cb.gatt_if); test_cb.gatt_if = 0; } break; } case 0x02: /* Connect */ { LOG_DEBUG(LOG_TAG, "%s: CONNECT - device=%02x:%02x:%02x:%02x:%02x:%02x (dev_type=%d, addr_type=%d)", __FUNCTION__, params->bda1->address[0], params->bda1->address[1], params->bda1->address[2], params->bda1->address[3], params->bda1->address[4], params->bda1->address[5], params->u1, params->u2); if (params->u1 == BT_DEVICE_TYPE_BLE) BTM_SecAddBleDevice(params->bda1->address, NULL, BT_DEVICE_TYPE_BLE, params->u2); if ( !GATT_Connect(test_cb.gatt_if, params->bda1->address, TRUE, BT_TRANSPORT_LE) ) { LOG_ERROR(LOG_TAG, "%s: GATT_Connect failed!", __FUNCTION__); } break; } case 0x03: /* Disconnect */ { LOG_DEBUG(LOG_TAG, "%s: DISCONNECT - conn_id=%d", __FUNCTION__, test_cb.conn_id); GATT_Disconnect(test_cb.conn_id); break; } case 0x04: /* Discover */ { char buf[50] = {0}; tGATT_DISC_PARAM param; memset(¶m, 0, sizeof(tGATT_DISC_PARAM)); if (params->u1 >= GATT_DISC_MAX) { LOG_ERROR(LOG_TAG, "%s: DISCOVER - Invalid type (%d)!", __FUNCTION__, params->u1); return 0; } param.s_handle = params->u2; param.e_handle = params->u3; btif_to_bta_uuid(¶m.service, params->uuid1); LOG_DEBUG(LOG_TAG, "%s: DISCOVER (%s), conn_id=%d, uuid=%s, handles=0x%04x-0x%04x", __FUNCTION__, disc_name[params->u1], test_cb.conn_id, format_uuid(param.service, buf), params->u2, params->u3); GATTC_Discover(test_cb.conn_id, params->u1, ¶m); break; } case 0xF0: /* Pairing configuration */ LOG_DEBUG(LOG_TAG, "%s: Setting pairing config auth=%d, iocaps=%d, keys=%d/%d/%d", __FUNCTION__, params->u1, params->u2, params->u3, params->u4, params->u5); bte_appl_cfg.ble_auth_req = params->u1; bte_appl_cfg.ble_io_cap = params->u2; bte_appl_cfg.ble_init_key = params->u3; bte_appl_cfg.ble_resp_key = params->u4; bte_appl_cfg.ble_max_key_size = params->u5; break; default: LOG_ERROR(LOG_TAG, "%s: UNKNOWN TEST COMMAND 0x%02x", __FUNCTION__, command); break; } return 0; }