void endstate( dict *d, lin_dict *ko_ld, node_value *base_nodes, node_value *pass_nodes, node_value *ko_nodes, state *s, node_value parent_v, int turn, int low_player ) { if (s->passes == 2) { if (turn) { stones_t temp = s->player; s->player = s->opponent; s->opponent = temp; } return; } state child_; state *child = &child_; for (int j = -1; j < STATE_SIZE; j++) { *child = *s; stones_t move; if (j == -1){ move = 0; } else { move = 1UL << j; } node_value child_v; if (make_move(child, move)) { canonize(child); size_t child_key = to_key(child); if (child->passes == 2){ value_t score = liberty_score(child); child_v = (node_value) {score, score, 0, 0}; } else if (child->passes == 1) { child_v = pass_nodes[key_index(d, child_key)]; } else if (child->ko) { child_key = child_key * STATE_SIZE + bitscan(child->ko); child_v = ko_nodes[lin_key_index(ko_ld, child_key)]; } else { child_v = base_nodes[key_index(d, child_key)]; } int is_best_child = (-child_v.high == parent_v.low && child_v.high_distance + 1 == parent_v.low_distance); is_best_child = low_player ? is_best_child : (-child_v.low == parent_v.high && child_v.low_distance + 1 == parent_v.high_distance); if (is_best_child) { *s = *child; endstate( d, ko_ld, base_nodes, pass_nodes, ko_nodes, s, child_v, !turn, !low_player ); } } } }
// scan services void test_scan_services() { // setup hashdb_settings_t settings; rm_hashdb_dir(temp_dir1); commands_t::create(settings, temp_dir1); commands_t::import(temp_dir1, sample_dfxml4096, "repository1"); // scan commands_t::scan(temp_dir1, sample_dfxml4096); hash_t k1; to_key(1, k1); commands_t::scan_hash(temp_dir1, k1.hexdigest()); }
int main(int argc, char *argv[]) { if (argc != 3) { printf("Usage: %s width height\n", argv[0]); return 0; } int width = atoi(argv[1]); int height = atoi(argv[2]); if (width <= 0) { printf("Width must be larger than 0.\n"); return 0; } if (width >= 7) { printf("Width must be less than 7.\n"); return 0; } if (height <= 0) { printf("Height must be larger than 0.\n"); return 0; } if (height >= 6) { printf("Height must be less than 6.\n"); return 0; } state s_ = (state) {rectangle(width, height), 0, 0, 0, 0}; state *s = &s_; dict d_; dict *d = &d_; size_t max_k = max_key(s); init_dict(d, max_k); size_t key_min = ~0; size_t key_max = 0; size_t total_legal = 0; for (size_t k = 0; k < max_k; k++) { if (!from_key(s, k)){ continue; } total_legal++; canonize(s); size_t key = to_key(s); add_key(d, key); if (key < key_min) { key_min = key; } if (key > key_max) { key_max = key; } } resize_dict(d, key_max); finalize_dict(d); size_t num_states = num_keys(d); printf("Total legal positions %zu\n", total_legal); printf("Total unique positions %zu\n", num_states); node_value *base_nodes = (node_value*) malloc(num_states * sizeof(node_value)); node_value *pass_nodes = (node_value*) malloc(num_states * sizeof(node_value)); value_t *leaf_nodes = (value_t*) malloc(num_states * sizeof(value_t)); lin_dict ko_ld_ = (lin_dict) {0, 0, 0, NULL}; lin_dict *ko_ld = &ko_ld_; state child_; state *child = &child_; size_t child_key; size_t key = key_min; for (size_t i = 0; i < num_states; i++) { assert(from_key(s, key)); value_t score = liberty_score(s); leaf_nodes[i] = score; pass_nodes[i] = (node_value) {VALUE_MIN, VALUE_MAX, DISTANCE_MAX, DISTANCE_MAX}; base_nodes[i] = (node_value) {VALUE_MIN, VALUE_MAX, DISTANCE_MAX, DISTANCE_MAX}; for (int j = 0; j < STATE_SIZE; j++) { *child = *s; if (make_move(child, 1UL << j)) { if (child->ko) { canonize(child); child_key = to_key(child) * STATE_SIZE + bitscan(child->ko); add_lin_key(ko_ld, child_key); } } } key = next_key(d, key); } finalize_lin_dict(ko_ld); node_value *ko_nodes = (node_value*) malloc(ko_ld->num_keys * sizeof(node_value)); printf("Unique positions with ko %zu\n", ko_ld->num_keys); for (size_t i = 0; i < ko_ld->num_keys; i++) { ko_nodes[i] = (node_value) {VALUE_MIN, VALUE_MAX, DISTANCE_MAX, DISTANCE_MAX}; } #ifndef PRELOAD printf("Negamax with Chinese rules.\n"); iterate( d, ko_ld, base_nodes, pass_nodes, ko_nodes, leaf_nodes, s, key_min, 0 ); #endif char dir_name[16]; sprintf(dir_name, "%dx%d", width, height); struct stat sb; if (stat(dir_name, &sb) == -1) { mkdir(dir_name, 0700); } assert(chdir(dir_name) == 0); FILE *f; #ifndef PRELOAD f = fopen("d_slots.dat", "wb"); fwrite((void*) d->slots, sizeof(slot_t), d->num_slots, f); fclose(f); f = fopen("d_checkpoints.dat", "wb"); fwrite((void*) d->checkpoints, sizeof(size_t), (d->num_slots >> 4) + 1, f); fclose(f); f = fopen("ko_ld_keys.dat", "wb"); fwrite((void*) ko_ld->keys, sizeof(size_t), ko_ld->num_keys, f); fclose(f); f = fopen("base_nodes.dat", "wb"); fwrite((void*) base_nodes, sizeof(node_value), num_states, f); fclose(f); f = fopen("pass_nodes.dat", "wb"); fwrite((void*) pass_nodes, sizeof(node_value), num_states, f); fclose(f); f = fopen("leaf_nodes.dat", "wb"); fwrite((void*) leaf_nodes, sizeof(value_t), num_states, f); fclose(f); f = fopen("ko_nodes.dat", "wb"); fwrite((void*) ko_nodes, sizeof(node_value), ko_ld->num_keys, f); fclose(f); #endif #ifdef PRELOAD f = fopen("base_nodes.dat", "rb"); fread((void*) base_nodes, sizeof(node_value), num_states, f); fclose(f); f = fopen("pass_nodes.dat", "rb"); fread((void*) pass_nodes, sizeof(node_value), num_states, f); fclose(f); f = fopen("leaf_nodes.dat", "rb"); fread((void*) leaf_nodes, sizeof(value_t), num_states, f); fclose(f); f = fopen("ko_nodes.dat", "rb"); fread((void*) ko_nodes, sizeof(node_value), ko_ld->num_keys, f); fclose(f); #endif // Japanese leaf state calculation. state new_s_; state *new_s = &new_s_; key = key_min; for (size_t i = 0; i < num_states; i++) { assert(from_key(s, key)); stones_t empty = s->playing_area & ~(s->player | s->opponent); *new_s = *s; endstate( d, ko_ld, base_nodes, pass_nodes, ko_nodes, new_s, base_nodes[i], 0, 1 ); stones_t player_controlled = new_s->player | liberties(new_s->player, new_s->playing_area & ~new_s->opponent); stones_t opponent_controlled = new_s->opponent | liberties(new_s->opponent, new_s->playing_area & ~new_s->player); value_t score = popcount(player_controlled & empty) - popcount(opponent_controlled & empty); score += 2 * (popcount(player_controlled & s->opponent) - popcount(opponent_controlled & s->player)); leaf_nodes[i] = score; *new_s = *s; endstate( d, ko_ld, base_nodes, pass_nodes, ko_nodes, new_s, base_nodes[i], 0, 0 ); player_controlled = new_s->player | liberties(new_s->player, new_s->playing_area & ~new_s->opponent); opponent_controlled = new_s->opponent | liberties(new_s->opponent, new_s->playing_area & ~new_s->player); score = popcount(player_controlled & empty) - popcount(opponent_controlled & empty); score += 2 * (popcount(player_controlled & s->opponent) - popcount(opponent_controlled & s->player)); leaf_nodes[i] += score; key = next_key(d, key); } // Clear the rest of the tree. for (size_t i = 0; i < num_states; i++) { pass_nodes[i] = (node_value) {VALUE_MIN, VALUE_MAX, DISTANCE_MAX, DISTANCE_MAX}; base_nodes[i] = (node_value) {VALUE_MIN, VALUE_MAX, DISTANCE_MAX, DISTANCE_MAX}; } for (size_t i = 0; i < ko_ld->num_keys; i++) { ko_nodes[i] = (node_value) {VALUE_MIN, VALUE_MAX, DISTANCE_MAX, DISTANCE_MAX}; } printf("Negamax with Japanese rules.\n"); iterate( d, ko_ld, base_nodes, pass_nodes, ko_nodes, leaf_nodes, s, key_min, 1 ); f = fopen("base_nodes_j.dat", "wb"); fwrite((void*) base_nodes, sizeof(node_value), num_states, f); fclose(f); f = fopen("pass_nodes_j.dat", "wb"); fwrite((void*) pass_nodes, sizeof(node_value), num_states, f); fclose(f); f = fopen("leaf_nodes_j.dat", "wb"); fwrite((void*) leaf_nodes, sizeof(value_t), num_states, f); fclose(f); f = fopen("ko_nodes_j.dat", "wb"); fwrite((void*) ko_nodes, sizeof(node_value), ko_ld->num_keys, f); fclose(f); return 0; }
void iterate( dict *d, lin_dict *ko_ld, node_value *base_nodes, node_value *pass_nodes, node_value *ko_nodes, value_t *leaf_nodes, state *s, size_t key_min, int japanese_rules ) { state child_; state *child = &child_; size_t num_states = num_keys(d); int changed = 1; while (changed) { changed = 0; size_t key = key_min; for (size_t i = 0; i < 2 * num_states + ko_ld->num_keys; i++) { if (i < 2 * num_states) { assert(from_key(s, key)); if (i % 2 == 1) { s->passes = 1; } } else { key = ko_ld->keys[i - 2 * num_states]; size_t ko_pos = key % STATE_SIZE; key /= STATE_SIZE; assert(from_key(s, key)); s->ko = 1UL << ko_pos; } node_value new_v = (node_value) {VALUE_MIN, VALUE_MIN, DISTANCE_MAX, 0}; for (int j = -1; j < STATE_SIZE; j++) { size_t child_key; node_value child_v; *child = *s; stones_t move; if (j == -1){ move = 0; } else { move = 1UL << j; } if (make_move(child, move)) { canonize(child); child_key = to_key(child); if (child->passes == 2){ value_t score = leaf_nodes[key_index(d, child_key)]; child_v = (node_value) {score, score, 0, 0}; } else if (child->passes == 1) { child_v = pass_nodes[key_index(d, child_key)]; } else if (child->ko) { child_key = child_key * STATE_SIZE + bitscan(child->ko); child_v = ko_nodes[lin_key_index(ko_ld, child_key)]; } else { child_v = base_nodes[key_index(d, child_key)]; } if (japanese_rules) { int prisoners = (popcount(s->opponent) - popcount(child->player)) * PRISONER_VALUE; if (child_v.low > VALUE_MIN) { child_v.low = child_v.low - prisoners; } if (child_v.high < VALUE_MAX) { child_v.high = child_v.high - prisoners; } } new_v = negamax(new_v, child_v); } } assert(new_v.high_distance > 0); if (i < 2 * num_states) { if (i % 2 == 0) { assert(new_v.low_distance > 1); assert(new_v.high_distance > 1); assert(new_v.low >= base_nodes[i / 2].low); assert(new_v.high <= base_nodes[i / 2].high); changed = changed || !equal(base_nodes[i / 2], new_v); base_nodes[i / 2] = new_v; } else { changed = changed || !equal(pass_nodes[i / 2], new_v); pass_nodes[i / 2] = new_v; key = next_key(d, key); } } else { changed = changed || !equal(ko_nodes[i - 2 * num_states], new_v); ko_nodes[i - 2 * num_states] = new_v; } } print_node(base_nodes[0]); } for (size_t i = 0; i < ko_ld->num_keys; i++) { assert(ko_nodes[i].low_distance > 2); assert(ko_nodes[i].high_distance > 2); } for (size_t i = 0; i < num_states; i++) { assert(base_nodes[i].low_distance > 1); assert(base_nodes[i].high_distance > 1); assert(pass_nodes[i].low_distance > 0); assert(pass_nodes[i].high_distance > 0); } }
void rw_new_tests() { // valid hashdigest values hash_t k1; hash_t k2; to_key(1, k1); to_key(2, k2); hashdb_element_t element; // create working changes object hashdb_changes_t changes; // open new hashdb manager hashdb_manager_t manager(temp_dir, RW_NEW); // ************************************************************ // initial state // ************************************************************ // check initial size BOOST_TEST_EQ(manager.map_size(), 0); // check initial iterator BOOST_TEST_EQ((manager.begin() == manager.end()), true); // ************************************************************ // insert, remove, and hashdb_changes variables // note: some of these tests additionally test failure ordering // ************************************************************ // insert valid element = hashdb_element_t(k1, 4096, "rep1", "file1", 0); manager.insert(element, changes); BOOST_TEST_EQ(changes.hashes_inserted, 1); BOOST_TEST_EQ(manager.map_size(), 1); // insert, mismatched hash block size element = hashdb_element_t(k1, 5, "rep1", "file1", 0); manager.insert(element, changes); BOOST_TEST_EQ(changes.hashes_not_inserted_mismatched_hash_block_size, 1); BOOST_TEST_EQ(manager.map_size(), 1); // insert, file offset not aligned element = hashdb_element_t(k1, 4096, "rep1", "file1", 5); manager.insert(element, changes); BOOST_TEST_EQ(changes.hashes_not_inserted_invalid_byte_alignment, 1); BOOST_TEST_EQ(manager.map_size(), 1); // insert, no exact duplicates element = hashdb_element_t(k2, 4096, "rep1", "file1", 4096); manager.insert(element, changes); BOOST_TEST_EQ(changes.hashes_inserted, 2); BOOST_TEST_EQ(manager.map_size(), 2); manager.insert(element, changes); BOOST_TEST_EQ(changes.hashes_not_inserted_duplicate_element, 1); BOOST_TEST_EQ(manager.map_size(), 2); // max 4 elements of same hash element = hashdb_element_t(k2, 4096, "rep1", "file1", 0); manager.insert(element, changes); element = hashdb_element_t(k2, 4096, "rep1", "file2", 4096); manager.insert(element, changes); element = hashdb_element_t(k2, 4096, "rep2", "file1", 4096); manager.insert(element, changes); element = hashdb_element_t(k2, 4096, "rep3", "file1", 4096); // too many manager.insert(element, changes); BOOST_TEST_EQ(changes.hashes_not_inserted_exceeds_max_duplicates, 1); BOOST_TEST_EQ(manager.map_size(), 5); // delete elements of same hash element = hashdb_element_t(k2, 4096, "rep3", "file1", 4096); // not present manager.remove(element, changes); BOOST_TEST_EQ(changes.hashes_removed, 0); BOOST_TEST_EQ(changes.hashes_not_removed_no_element, 1); BOOST_TEST_EQ(manager.map_size(), 5); element = hashdb_element_t(k2, 4096, "rep1", "file1", 4096); manager.remove(element, changes); element = hashdb_element_t(k2, 4096, "rep1", "file1", 0); manager.remove(element, changes); element = hashdb_element_t(k2, 4096, "rep1", "file2", 4096); manager.remove(element, changes); element = hashdb_element_t(k2, 4096, "rep2", "file1", 4096); manager.remove(element, changes); BOOST_TEST_EQ(changes.hashes_removed, 4); BOOST_TEST_EQ(changes.hashes_not_removed_no_element, 1); BOOST_TEST_EQ(manager.map_size(), 1); // remove, entry of single element element = hashdb_element_t(k1, 4096, "rep1", "file1", 0); manager.remove(element, changes); BOOST_TEST_EQ(changes.hashes_removed, 5); BOOST_TEST_EQ(changes.hashes_not_removed_no_element, 1); BOOST_TEST_EQ(manager.map_size(), 0); // remove, no element element = hashdb_element_t(k1, 4096, "rep1", "file1", 0); manager.remove(element, changes); BOOST_TEST_EQ(changes.hashes_not_removed_no_element, 2); BOOST_TEST_EQ(manager.map_size(), 0); // insert, valid, previously deleted element = hashdb_element_t(k1, 4096, "rep1", "file1", 0); manager.insert(element, changes); BOOST_TEST_EQ(changes.hashes_inserted, 6); // remove_key successfully manager.remove_key(k1, changes); BOOST_TEST_EQ(changes.hashes_removed, 6); // add two of same key then remove_key successfully element = hashdb_element_t(k2, 4096, "rep1", "file1", 0); manager.insert(element, changes); element = hashdb_element_t(k2, 4096, "rep1", "file2", 4096); manager.insert(element, changes); manager.remove_key(k2, changes); BOOST_TEST_EQ(changes.hashes_removed, 8); // remove_key no hash manager.remove_key(k1, changes); BOOST_TEST_EQ(changes.hashes_not_removed_no_hash, 1); // remove, mismatched hash block size element = hashdb_element_t(k1, 5, "rep1", "file1", 0); manager.remove(element, changes); BOOST_TEST_EQ(changes.hashes_not_removed_mismatched_hash_block_size, 1); // remove, file offset not aligned element = hashdb_element_t(k1, 4096, "rep1", "file1", 5); manager.remove(element, changes); BOOST_TEST_EQ(changes.hashes_not_removed_invalid_byte_alignment, 1); // remove, no element element = hashdb_element_t(k2, 4096, "rep1", "file1", 0); manager.remove(element, changes); BOOST_TEST_EQ(changes.hashes_not_removed_no_element, 3); // ************************************************************ // find, find_count, size, iterator // ************************************************************ BOOST_TEST_EQ(manager.find_count(k1), 0); BOOST_TEST_EQ(manager.find_count(k1), 0); // setup with one element to make iterator simple element = hashdb_element_t(k1, 4096, "rep1", "file1", 0); manager.insert(element, changes); BOOST_TEST_EQ(manager.map_size(), 1); hashdb_iterator_t it(manager.begin()); BOOST_TEST_EQ(it->key, k1); BOOST_TEST_EQ(it->hash_block_size, 4096); BOOST_TEST_EQ(it->repository_name, "rep1"); BOOST_TEST_EQ(it->filename, "file1"); BOOST_TEST_EQ(it->file_offset, 0); BOOST_TEST_EQ((*it).file_offset, 0); ++it; BOOST_TEST_EQ((it == manager.end()), true); // setup with two elements under one key and one element under another key element = hashdb_element_t(k1, 4096, "second_rep1", "file1", 0); manager.insert(element, changes); element = hashdb_element_t(k2, 4096, "rep1", "file1", 0); manager.insert(element, changes); BOOST_TEST_EQ(manager.find_count(k1), 2); BOOST_TEST_EQ(manager.map_size(), 3); hashdb_iterator_t it2(manager.begin()); ++it2; it2++; ++it2; BOOST_TEST_EQ((it2 == manager.end()), true); // check iterator pair from find std::pair<hashdb_iterator_t, hashdb_iterator_t> it_pair; it_pair = manager.find(k1); ++it_pair.first; ++it_pair.first; BOOST_TEST_EQ((it_pair.first == it_pair.second), true); it_pair = manager.find(k1); ++it_pair.first; ++it_pair.first; BOOST_TEST_EQ((it_pair.first == it_pair.second), true); // ************************************************************ // install lots of data // ************************************************************ // populate with 1,000,000 entries hash_t key; BOOST_TEST_EQ(manager.map_size(), 3); for (uint64_t n=0; n< 1000000; ++n) { to_key(n+1000000, key); element = hashdb_element_t(key, 4096, "rep1", "file1", 0); manager.insert(element, changes); } BOOST_TEST_EQ(manager.map_size(), 1000003); }
int main(int argc, char *argv[]) { if (argc != 3 && argc != 4) { printf("Usage: %s width height high_path\n", argv[0]); return 0; } int width = atoi(argv[1]); int height = atoi(argv[2]); if (width <= 0) { printf("Width must be larger than 0.\n"); return 0; } if (width >= 7) { printf("Width must be less than 7.\n"); return 0; } if (height <= 0) { printf("Height must be larger than 0.\n"); return 0; } if (height >= 6) { printf("Height must be less than 6.\n"); return 0; } int player_low = 1; if (argc == 4) { player_low = 0; } state s_ = (state) {rectangle(width, height), 0, 0, 0, 0}; state *s = &s_; char dir_name[16]; sprintf(dir_name, "%dx%d", width, height); assert(chdir(dir_name) == 0); dict d_; dict *d = &d_; d->num_slots = load_dat("d_slots.dat", (void**) &(d->slots), sizeof(slot_t)); load_dat("d_checkpoints.dat", (void**) &(d->checkpoints), sizeof(size_t)); lin_dict ko_ld_; lin_dict *ko_ld = &ko_ld_; ko_ld->num_keys = load_dat("ko_ld_keys.dat", (void**) &(ko_ld->keys), sizeof(size_t)); node_value *base_nodes; load_dat("base_nodes_j.dat", (void**) &base_nodes, sizeof(node_value)); node_value *pass_nodes; load_dat("pass_nodes_j.dat", (void**) &pass_nodes, sizeof(node_value)); node_value *ko_nodes; load_dat("ko_nodes_j.dat", (void**) &ko_nodes, sizeof(node_value)); value_t *leaf_nodes; load_dat("leaf_nodes_j.dat", (void**) &leaf_nodes, sizeof(value_t)); canonize(s); inspect( d, ko_ld, base_nodes, pass_nodes, ko_nodes, leaf_nodes, s, base_nodes[key_index(d, to_key(s))], player_low, 1 ); /* FILE *f; f = fopen("d_slots.dat", "wb"); fwrite((void*) d->slots, sizeof(slot_t), d->num_slots, f); fclose(f); f = fopen("d_checkpoints.dat", "wb"); fwrite((void*) d->checkpoints, sizeof(size_t), (d->num_slots >> 4) + 1, f); fclose(f); f = fopen("ko_ld_keys.dat", "wb"); fwrite((void*) ko_ld->keys, sizeof(size_t), ko_ld->num_keys, f); fclose(f); */ }
void inspect( dict *d, lin_dict *ko_ld, node_value *base_nodes, node_value *pass_nodes, node_value *ko_nodes, value_t *leaf_nodes, state *s, node_value parent_v, int low_player, int japanese_rules ) { print_state(s); print_node(parent_v); if (s->passes == 2){ return; } state child_; state *child = &child_; for (int j = -1; j < STATE_SIZE; j++) { *child = *s; stones_t move; if (j == -1){ move = 0; } else { move = 1UL << j; } node_value child_v; if (make_move(child, move)) { canonize(child); size_t child_key = to_key(child); if (child->passes == 2){ value_t score = leaf_nodes[key_index(d, child_key)]; child_v = (node_value) {score, score, 0, 0}; } else if (child->passes == 1) { child_v = pass_nodes[key_index(d, child_key)]; } else if (child->ko) { child_key = child_key * STATE_SIZE + bitscan(child->ko); child_v = ko_nodes[lin_key_index(ko_ld, child_key)]; } else { child_v = base_nodes[key_index(d, child_key)]; } node_value child_tree_v = child_v; if (japanese_rules) { int prisoners = (popcount(s->opponent) - popcount(child->player)) * PRISONER_VALUE; if (child_v.low > VALUE_MIN) { child_v.low = child_v.low - prisoners; } if (child_v.high < VALUE_MAX) { child_v.high = child_v.high - prisoners; } } int is_best_child = (-child_v.high == parent_v.low && child_v.high_distance + 1 == parent_v.low_distance); is_best_child = low_player ? is_best_child : (-child_v.low == parent_v.high && child_v.low_distance + 1 == parent_v.high_distance); if (is_best_child) { *s = *child; inspect( d, ko_ld, base_nodes, pass_nodes, ko_nodes, leaf_nodes, s, child_tree_v, !low_player, japanese_rules ); return; } } } assert(0); }
int flashnode_build_config(struct list_head *params, struct flashnode_rec *fnode, struct iovec *iovs) { struct user_param *param; struct iovec *iov = NULL; int count = 0; int port = 3260; /* start at 2, because 0 is for nlmsghdr and 1 for event */ iov = iovs + 2; list_for_each_entry(param, params, list) { if (!strcmp(param->name, FLASHNODE_SESS_AUTO_SND_TGT_DISABLE)) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_AUTO_SND_TGT_DISABLE, fnode->sess.auto_snd_tgt_disable)) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_DISCOVERY_SESS)) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_DISCOVERY_SESS, fnode->sess.discovery_session)) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_ENTRY_EN)) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_ENTRY_EN, fnode->sess.entry_enable)) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_IMM_DATA_EN)) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_IMM_DATA_EN, fnode->sess.immediate_data)) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_INITIAL_R2T_EN)) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_INITIAL_R2T_EN, fnode->sess.initial_r2t)) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_DATASEQ_INORDER)) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_DATASEQ_INORDER, fnode->sess.data_seq_in_order)) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_PDU_INORDER)) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_PDU_INORDER, fnode->sess.data_pdu_in_order)) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_CHAP_AUTH_EN)) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_CHAP_AUTH_EN, fnode->sess.chap_auth_en)) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_DISCOVERY_LOGOUT_EN)) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_DISCOVERY_LOGOUT_EN, fnode->sess.discovery_logout_en)) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_BIDI_CHAP_EN )) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_BIDI_CHAP_EN, fnode->sess.bidi_chap_en)) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_DISCOVERY_AUTH_OPTIONAL)) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_DISCOVERY_AUTH_OPTIONAL, fnode->sess.discovery_auth_optional)) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_ERL)) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_ERL, fnode->sess.erl)) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_DEF_TIME2WAIT)) { if (!flashnode_fill_uint16(fnode, &iov[count], ISCSI_FLASHNODE_DEF_TIME2WAIT, fnode->sess.def_time2wait)) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_DEF_TIME2RETAIN)) { if (!flashnode_fill_uint16(fnode, &iov[count], ISCSI_FLASHNODE_DEF_TIME2RETAIN, fnode->sess.def_time2retain)) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_MAX_R2T)) { if (!flashnode_fill_uint16(fnode, &iov[count], ISCSI_FLASHNODE_MAX_R2T, fnode->sess.max_outstanding_r2t)) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_TSID)) { if (!flashnode_fill_uint16(fnode, &iov[count], ISCSI_FLASHNODE_TSID, fnode->sess.tsid)) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_MAX_BURST)) { if (!flashnode_fill_uint32(fnode, &iov[count], ISCSI_FLASHNODE_MAX_BURST, fnode->sess.max_burst_len)) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_DEF_TASKMGMT_TMO)) { if (!flashnode_fill_uint16(fnode, &iov[count], ISCSI_FLASHNODE_DEF_TASKMGMT_TMO, fnode->sess.def_taskmgmt_tmo)) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_NAME)) { if (!flashnode_fill_str(fnode, &iov[count], ISCSI_FLASHNODE_NAME, fnode->sess.targetname, sizeof(fnode->sess.targetname))) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_FIRST_BURST)) { if (!flashnode_fill_uint32(fnode, &iov[count], ISCSI_FLASHNODE_FIRST_BURST, fnode->sess.first_burst_len)) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_ISID)) { if (!flashnode_fill_isid(fnode, &iov[count])) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_ALIAS)) { if (!flashnode_fill_str(fnode, &iov[count], ISCSI_FLASHNODE_ALIAS, fnode->sess.targetalias, sizeof(fnode->sess.targetalias))) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_TPGT)) { if (!flashnode_fill_uint16(fnode, &iov[count], ISCSI_FLASHNODE_TPGT, fnode->sess.tpgt)) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_DISCOVERY_PARENT_IDX)) { if (!flashnode_fill_uint16(fnode, &iov[count], ISCSI_FLASHNODE_DISCOVERY_PARENT_IDX, fnode->sess.discovery_parent_idx)) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_DISCOVERY_PARENT_TYPE)) { if (!flashnode_fill_str(fnode, &iov[count], ISCSI_FLASHNODE_DISCOVERY_PARENT_TYPE, fnode->sess.discovery_parent_type, sizeof(fnode->sess.discovery_parent_type))) count++; } else if (!strcmp(param->name, FLASHNODE_SESS_PORTAL_TYPE)) { if (!flashnode_fill_str(fnode, &iov[count], ISCSI_FLASHNODE_PORTAL_TYPE, fnode->sess.portal_type, sizeof(fnode->sess.portal_type))) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_SESS_CHAP_OUT_IDX))) { if (!flashnode_fill_uint32(fnode, &iov[count], ISCSI_FLASHNODE_CHAP_OUT_IDX, fnode->sess.chap_out_idx)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_PORT))) { if (fnode->conn[0].port) port = fnode->conn[0].port; if (!flashnode_fill_uint16(fnode, &iov[count], ISCSI_FLASHNODE_PORT, port)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_IPADDR))) { if (!flashnode_fill_ipaddr(fnode, &iov[count], ISCSI_FLASHNODE_IPADDR)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_MAX_RECV_DLENGTH))) { if (!flashnode_fill_uint32(fnode, &iov[count], ISCSI_FLASHNODE_MAX_RECV_DLENGTH, fnode->conn[0].max_recv_dlength)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_IS_FW_ASSIGNED_IPV6))) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_IS_FW_ASSIGNED_IPV6, fnode->conn[0].is_fw_assigned_ipv6)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_HDR_DGST_EN))) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_HDR_DGST_EN, fnode->conn[0].header_digest_en)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_DATA_DGST_EN))) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_DATA_DGST_EN, fnode->conn[0].data_digest_en)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_SNACK_REQ_EN))) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_SNACK_REQ_EN, fnode->conn[0].snack_req_en)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_TCP_TIMESTAMP_STAT))) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_TCP_TIMESTAMP_STAT, fnode->conn[0].tcp_timestamp_stat)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_TCP_NAGLE_DISABLE))) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_TCP_NAGLE_DISABLE, fnode->conn[0].tcp_nagle_disable)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_TCP_WSF_DISABLE))) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_TCP_WSF_DISABLE, fnode->conn[0].tcp_wsf_disable)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_TCP_TIMER_SCALE))) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_TCP_TIMER_SCALE, fnode->conn[0].tcp_timer_scale)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_TCP_TIMESTAMP_EN))) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_TCP_TIMESTAMP_EN, fnode->conn[0].tcp_timestamp_en)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_IP_FRAG_DISABLE))) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_IP_FRAG_DISABLE, fnode->conn[0].fragment_disable)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_MAX_XMIT_DLENGTH))) { if (!flashnode_fill_uint32(fnode, &iov[count], ISCSI_FLASHNODE_MAX_XMIT_DLENGTH, fnode->conn[0].max_xmit_dlength)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_KEEPALIVE_TMO))) { if (!flashnode_fill_uint16(fnode, &iov[count], ISCSI_FLASHNODE_KEEPALIVE_TMO, fnode->conn[0].keepalive_tmo)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_REDIRECT_IPADDR))) { if (!flashnode_fill_ipaddr(fnode, &iov[count], ISCSI_FLASHNODE_REDIRECT_IPADDR)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_MAX_SEGMENT_SIZE))) { if (!flashnode_fill_uint32(fnode, &iov[count], ISCSI_FLASHNODE_MAX_SEGMENT_SIZE, fnode->conn[0].max_segment_size)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_LOCAL_PORT))) { if (!flashnode_fill_uint16(fnode, &iov[count], ISCSI_FLASHNODE_LOCAL_PORT, fnode->conn[0].local_port)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_IPV4_TOS))) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_IPV4_TOS, fnode->conn[0].ipv4_tos)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_IPV6_TC))) { if (!flashnode_fill_uint8(fnode, &iov[count], ISCSI_FLASHNODE_IPV6_TC, fnode->conn[0].ipv6_traffic_class)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_IPV6_FLOW_LABEL))) { if (!flashnode_fill_uint16(fnode, &iov[count], ISCSI_FLASHNODE_IPV6_FLOW_LABEL, fnode->conn[0].ipv6_flow_lbl)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_LINK_LOCAL_IPV6))) { if (!flashnode_fill_ipv6_addr(fnode, &iov[count], ISCSI_FLASHNODE_LINK_LOCAL_IPV6)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_TCP_XMIT_WSF))) { if (!flashnode_fill_uint32(fnode, &iov[count], ISCSI_FLASHNODE_TCP_XMIT_WSF, fnode->conn[0].tcp_xmit_wsf)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_TCP_RECV_WSF))) { if (!flashnode_fill_uint32(fnode, &iov[count], ISCSI_FLASHNODE_TCP_RECV_WSF, fnode->conn[0].tcp_recv_wsf)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_STATSN))) { if (!flashnode_fill_uint32(fnode, &iov[count], ISCSI_FLASHNODE_STATSN, fnode->conn[0].stat_sn)) count++; } else if (!strcmp(param->name, to_key(FLASHNODE_CONN_EXP_STATSN))) { if (!flashnode_fill_uint32(fnode, &iov[count], ISCSI_FLASHNODE_EXP_STATSN, fnode->conn[0].exp_stat_sn)) count++; } } return count; }