#ifndef cp2_cco_bw_prio_heap_h #define cp2_cco_bw_prio_heap_h /* Cesar project {{{ * * Copyright (C) 2008 Spidcom * * <<>> * * }}} */ /** * \file cp_cco_bw_prio_heap.h * \brief « brief description » * \ingroup « module » * * « long description » */ #include "lib/list.h" #include "cp2/cp.h" /** * connection storage regarding to its priority and time arrival. */ struct cp_cco_bw_prio_conn_t { /** * connection identifier */ u16 cid; /** * Allocation status true : allocated false : not allocated */ bool alloc_status; /** * Node of the List */ list_node_t node; }; typedef struct cp_cco_bw_prio_conn_t cp_cco_bw_prio_conn_t; /** * Table that stores the pending connection in order of arrival. Each * table has a specific priority level assigned (0 to 3). It manages the * order and return the most prior connection */ struct cp_cco_bw_prio_heap_t { /** * level of priority of the heap (4 different levels) */ u8 table_priority_level; /** * stage of the allocation. Faster to get to the next connection to * allocate. */ u32 nb_conn_allocated; /** * Number of connection into the heap * */ u32 nb_conn; /** * first connection of the heap */ list_t conns; }; typedef struct cp_cco_bw_prio_heap_t cp_cco_bw_prio_heap_t; /* * gets the most prior pending connection return its CID. * \param ctx the module context. * \return \todo fill this * */ cp_cco_bw_prio_conn_t* cp_cco_bw_prio_heap_get_most_prior_conn (cp_t *ctx); /** * delete a connection. * \param ctx the module context. * \param cid Connection identifier * */ void cp_cco_bw_prio_heap_del_conn (cp_t *ctx, u16 cid); /** * add a connection. * \param ctx the module context. * \param cid Connection identifier * */ void cp_cco_bw_prio_heap_add_conn (cp_t *ctx, u16 cid, u8 prio); /** * Clears the status of the allocation * \param ctx Control Plane Context * */ void cp_cco_bw_prio_heap_clear_conn(cp_t *ctx); /** * Init function */ void cp_cco_bw_prio_heap_init(cp_t *ctx); /** * Uninit function */ void cp_cco_bw_prio_heap_uninit(cp_t *ctx); #endif /* cp_cco_bw_prio_heap_h */