X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drl%2Fsimple.h;fp=drl%2Fsimple.h;h=1afb01690f54e6330e6c441fa8b0a4533ceff0c4;hb=0be9704d6b24d09ebd55beedec52758cb88c570b;hp=0000000000000000000000000000000000000000;hpb=6747e89080a8265aa73320bd9f40a0fa6e1c161e;p=distributedratelimiting.git diff --git a/drl/simple.h b/drl/simple.h new file mode 100644 index 0000000..1afb016 --- /dev/null +++ b/drl/simple.h @@ -0,0 +1,58 @@ +/* See the DRL-LICENSE file for this file's software license. */ + +/** + * Defines the simplest flow accouting table. It only keeps track of + * aggregate rate information in the common table. It does no + * individual flow accounting. + * + */ + +#ifndef _SIMPLE_ACCOUNTING_H_ +#define _SIMPLE_ACCOUNTING_H_ + +#include + +/** The "table" that stores the aggregate information. It's constructed of two + * main pieces. + */ +struct sim_flow_table { + + /* Pointer to the common flow information for the identity that owns this + * sampled flow table. This is updated with aggregate information. */ + common_accounting_t *common; + + uint32_t (*hash_function)(const key_flow *key); + +}; + +typedef struct sim_flow_table *simple_flow_table; + +/** + * Creates a new table. Note that the hash function is never used by this type + * of table. + * + * Returns the new table or NULL on failure. + */ +simple_flow_table simple_table_create(common_accounting_t *common); + +/** + * Destroys the specified table. + */ +void simple_table_destroy(simple_flow_table table); + +/** + * Updates the state of the table given a newly acquired packet. + * + * This function will always return zero because this type of table stores no + * flow information. + */ +int simple_table_sample(simple_flow_table table, const key_flow *key); + +/** Cleans the table. This is a no-op for this type of table. */ +int simple_table_cleanup(simple_flow_table table); + +/** Updates the aggregate rate information. */ +void simple_table_update_flows(simple_flow_table table, struct timeval now, +double ewma_weight); + +#endif /* _SIMPLE_ACCOUNTING_H_ */