1 #include "fwp_ctable.h"
4 void fwp_ctable_init(struct fwp_ctable* ctable)
8 for (i = 0; i < FWP_CONTRACT_MAX; i++)
9 ctable->entry[i].status = FWP_CTENTRY_EMPTY;
13 int fwp_ctable_put(struct fwp_ctable* ctable, struct fwp_ctable_entry* entry)
16 /* obtain fwp ctable mutex */
17 /* find free contract */
19 while ((ctable->entry[id].status != FWP_CTENTRY_EMPTY) &&
20 (id < FWP_CONTRACT_MAX)) id++;
22 if (id == FWP_CONTRACT_MAX) {
23 /* release fwp_contract_table mutex */
27 memcpy(&ctable->entry[id], entry, sizeof(struct fwp_ctable_entry));
28 ctable->entry[id].status = FWP_CTENTRY_FULL;
29 /* release fwp_contract_table mutex */
34 struct fwp_ctable_entry* fwp_ctable_get(struct fwp_ctable* ctable, unsigned int id)
36 return (&ctable->entry[id]);
39 inline void fwp_ctable_remove(struct fwp_ctable* ctable, unsigned int id)
41 ctable->entry[id].status = FWP_CTENTRY_EMPTY;