/** * Move a scoreboard entry from one table to the other * * @todo This actually can probably be done faster with the rindex * stuff and a SFXHASH_NODE interface. * * @param dst where to move the address to * @param src where to move the address from * @param address the address to move * * @return FLOW_SUCCESS on success */ int scoreboard_move(SCOREBOARD *dst, SCOREBOARD *src, u_int32_t *address) { SCORE_ENTRY *src_entry, *dst_entry; if(!src || !dst) { return FLOW_ENULL; } if(scoreboard_find(src, address, &src_entry) != FLOW_SUCCESS) { return FLOW_NOTFOUND; } if(scoreboard_add(dst, address, &dst_entry) != FLOW_SUCCESS) { return FLOW_EINVALID; } memcpy(dst_entry,src_entry,sizeof(SCORE_ENTRY)); dst_entry->position = dst->kind; if(scoreboard_remove(src, address) != FLOW_SUCCESS) { /* small problem here in that we have 2 versions of the same thing going on */ return FLOW_BADJUJU; } return FLOW_SUCCESS; }
int flowps_add_entry(PS_TRACKER *trackerp, TRACKER_POSITION position, u_int32_t *address, SCORE_ENTRY **sepp) { int ret; if(position == TRACKER_ACTIVE) { ret = scoreboard_add(&trackerp->table_active, address, sepp); } else { ret = scoreboard_add(&trackerp->table_scanner, address, sepp); } if(ret == FLOW_SUCCESS) { (*sepp)->position = position; } return ret; }