Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

scoreboard.c File Reference

#include "scoreboard.h"
#include "util_math.h"

Go to the source code of this file.

Functions

static void sb_init_entry (void)
static int scoreboard_anrfree (void *key, void *data)
static int scoreboard_usrfree (void *key, void *data)
static INLINE int scoreboard_lru (SCOREBOARD *sbp, SCORE_ENTRY **sepp)
static INLINE int scoreboard_mru (SCOREBOARD *sbp, SCORE_ENTRY **sepp)
int scoreboard_init (SCOREBOARD *sbp, char *description, TRACKER_POSITION kind, unsigned int rows, int memcap)
int scoreboard_destroy (SCOREBOARD *sbp)
int scoreboard_add (SCOREBOARD *sbp, u_int32_t *address, SCORE_ENTRY **sepp)
int scoreboard_remove (SCOREBOARD *sbp, u_int32_t *address)
int scoreboard_find (SCOREBOARD *sbp, u_int32_t *address, SCORE_ENTRY **sepp)
int scoreboard_move (SCOREBOARD *dst, SCOREBOARD *src, u_int32_t *address)
void scoreboard_dump (SCOREBOARD *ssp)
void scoreboard_stats (SCOREBOARD *sbp, int dumpall)
int scoreboard_memcap (SCOREBOARD *sbp)
int scoreboard_row_count (SCOREBOARD *sbp)
int scoreboard_overhead_bytes (SCOREBOARD *sbp)

Variables

static SCORE_ENTRY s_init_entry


Function Documentation

static void sb_init_entry void   )  [static]
 

initialize the static s_init_entry variable once and only once. This is used to zero out the key so that if the compiler pads the structure, we still have 0's in this keylookup.

Definition at line 263 of file scoreboard.c.

References memset.

Referenced by scoreboard_init().

int scoreboard_add SCOREBOARD sbp,
u_int32_t address,
SCORE_ENTRY **  sepp
 

Definition at line 89 of file scoreboard.c.

References FLOW_BADJUJU, FLOW_EINVALID, FLOW_ENOMEM, FLOW_ENULL, flow_printf(), FLOW_SUCCESS, _SCOREBOARD::ipv4_table, scoreboard_mru(), sfxhash_add(), SFXHASH_INTABLE, SFXHASH_NOMEM, and SFXHASH_OK.

Referenced by flowps_add_entry(), and scoreboard_move().

static int scoreboard_anrfree void *  key,
void *  data
[static]
 

Automatically recover nodes and make sure that all the other references are taken care of.

Parameters:
key hash key
data scoreboard entry
Returns:
0 if this node can be removed

Definition at line 328 of file scoreboard.c.

Referenced by scoreboard_init().

int scoreboard_destroy SCOREBOARD sbp  ) 
 

Definition at line 75 of file scoreboard.c.

References FLOW_ENULL, FLOW_SUCCESS, _SCOREBOARD::ipv4_table, NULL, and sfxhash_delete().

Referenced by flowps_destroy(), and flowps_init().

void scoreboard_dump SCOREBOARD ssp  ) 
 

Print out the entirety of the scoreboard

Parameters:
ssp unique tracker

Definition at line 210 of file scoreboard.c.

References _sfxhash_node::data, flow_printf(), flowps_entry_print(), _SCOREBOARD::ipv4_table, _sfxhash_node::key, NULL, sfxhash_ghead(), and sfxhash_gnext().

Referenced by scoreboard_stats().

int scoreboard_find SCOREBOARD sbp,
u_int32_t address,
SCORE_ENTRY **  sepp
 

Definition at line 145 of file scoreboard.c.

References FLOW_ENULL, FLOW_NOTFOUND, FLOW_SUCCESS, _SCOREBOARD::ipv4_table, NULL, and sfxhash_find().

Referenced by flowps_find_entry(), and scoreboard_move().

int scoreboard_init SCOREBOARD sbp,
char *  description,
TRACKER_POSITION  kind,
unsigned int  rows,
int  memcap
 

Create a new scoreboard for tracking nodes.

Parameters:
sbp scoreboard to initialize
at_thr active talker thresholds
sc_thr scanner thresholds (may not be needed)
kind tracker location for this table
description table description
rows number of rows to populate the initial HASHTABLE() with
memcap bytes we can spend on this scoreboard
Returns:
FLOW_SUCCESS on success, else failure

Definition at line 28 of file scoreboard.c.

References _SCOREBOARD::description, FLOW_EINVALID, FLOW_ENOMEM, FLOW_ENULL, flow_printf(), FLOW_SUCCESS, _SCOREBOARD::ipv4_table, _SCOREBOARD::kind, memset, NULL, sb_init_entry(), scoreboard_anrfree(), scoreboard_usrfree(), SDESC_SIZE, sfxhash_new(), and snprintf.

Referenced by flowps_init().

static INLINE int scoreboard_lru SCOREBOARD sbp,
SCORE_ENTRY **  sepp
[static]
 

Get the least recently used flow from the cache

Parameters:
sbp scoreboard to find
sepp score entry pointer to fill in
Returns:
FLOW_SUCCESS on sucess

Definition at line 304 of file scoreboard.c.

References FLOW_EINVALID, FLOW_NOTFOUND, FLOW_SUCCESS, _SCOREBOARD::ipv4_table, NULL, and sfxhash_lru().

int scoreboard_memcap SCOREBOARD sbp  ) 
 

get the memcap

Parameters:
sbp scoreboard ptr to return the memcap of
Returns:
memcap or -1

Definition at line 355 of file scoreboard.c.

References _SCOREBOARD::ipv4_table, _sfxhash::mc, MEMCAP::memcap, and NULL.

Referenced by FlowPSOutputConfig().

int scoreboard_move SCOREBOARD dst,
SCOREBOARD src,
u_int32_t address
 

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.
Parameters:
dst where to move the address to
src where to move the address from
address the address to move
Returns:
FLOW_SUCCESS on success

Definition at line 172 of file scoreboard.c.

References FLOW_BADJUJU, FLOW_EINVALID, FLOW_ENULL, FLOW_NOTFOUND, FLOW_SUCCESS, _SCOREBOARD::kind, memcpy, _PS_SCORE_ENTRY::position, scoreboard_add(), scoreboard_find(), and scoreboard_remove().

Referenced by flowps_newflow_callback().

static INLINE int scoreboard_mru SCOREBOARD sbp,
SCORE_ENTRY **  sepp
[static]
 

Get the most recently used flow from the cache

Parameters:
sbp scoreboard to find
sepp score entry pointer to fill in
Returns:
FLOW_SUCCESS on sucess

Definition at line 283 of file scoreboard.c.

References FLOW_EINVALID, FLOW_NOTFOUND, FLOW_SUCCESS, _SCOREBOARD::ipv4_table, NULL, and sfxhash_mru().

Referenced by scoreboard_add().

int scoreboard_overhead_bytes SCOREBOARD sbp  ) 
 

get the overhead # of bytes

Parameters:
sbp scoreboard ptr to return the memcap of
Returns:
nrows or -1

Definition at line 386 of file scoreboard.c.

References _SCOREBOARD::ipv4_table, NULL, and sfxhash_overhead_bytes().

Referenced by FlowPSOutputConfig().

int scoreboard_remove SCOREBOARD sbp,
u_int32_t address
 

Remove a node from the scoreboard

Parameters:
sbp scoreboard to modify
address address to remove
Returns:
FLOW_SUCCESS on success

Definition at line 130 of file scoreboard.c.

References FLOW_ENULL, FLOW_NOTFOUND, FLOW_SUCCESS, _SCOREBOARD::ipv4_table, and sfxhash_remove().

Referenced by scoreboard_move().

int scoreboard_row_count SCOREBOARD sbp  ) 
 

get the row count

Parameters:
sbp scoreboard ptr to return the memcap of
Returns:
nrows or -1

Definition at line 370 of file scoreboard.c.

References _SCOREBOARD::ipv4_table, _sfxhash::nrows, and NULL.

Referenced by FlowPSOutputConfig().

void scoreboard_stats SCOREBOARD sbp,
int  dumpall
 

Definition at line 232 of file scoreboard.c.

References calc_percent(), _SCOREBOARD::description, flow_printf(), _SCOREBOARD::ipv4_table, _sfxhash::mc, MEMCAP::memcap, scoreboard_dump(), sfxhash_anr_count(), sfxhash_count(), sfxhash_find_fail(), sfxhash_find_success(), sfxhash_find_total(), and sfxhash_overhead_bytes().

Referenced by flowps_stats().

static int scoreboard_usrfree void *  key,
void *  data
[static]
 

Automatically recover nodes and make sure that all the other references are taken care of.

Parameters:
key hash key
data scoreboard entry
Returns:
0 if this node can be removed

Definition at line 343 of file scoreboard.c.

Referenced by scoreboard_init().


Variable Documentation

SCORE_ENTRY s_init_entry [static]
 

Definition at line 4 of file scoreboard.c.


Generated on Sun May 14 14:51:24 2006 by  doxygen 1.4.2