blob: 4b1dcce554f8c05c494efb7e597144bf4f0fa391 [file] [log] [blame]
Neels Hofmeyrcbdfb782018-02-12 16:45:39 +01001/* Manage a list of penalty timers per BTS;
2 * initially used by handover algorithm 2 to keep per-BTS timers for each subscriber connection. */
3#pragma once
4
5/* Opaque struct to manage penalty timers */
6struct penalty_timers;
7
8/* Initialize a list of penalty timers.
9 * param ctx: talloc context to allocate in.
10 * returns an empty struct penalty_timers. */
11struct penalty_timers *penalty_timers_init(void *ctx);
12
13/* Add a penalty timer for a BTS.
14 * param pt: penalty timers list as from penalty_timers_init().
15 * param for_object: arbitrary pointer reference to store a penalty timer for (passing NULL is possible,
16 * but note that penalty_timers_clear() will clear all timers if given for_object=NULL).
17 * param timeout: penalty time in seconds. */
18void penalty_timers_add(struct penalty_timers *pt, void *for_object, int timeout);
19
20/* Return the amount of penalty time remaining for a BTS.
21 * param pt: penalty timers list as from penalty_timers_init().
22 * param for_object: arbitrary pointer reference to query penalty timers for.
23 * returns seconds remaining until all penalty time has expired. */
24unsigned int penalty_timers_remaining(struct penalty_timers *pt, void *for_object);
25
26/* Clear penalty timers for one or all BTS.
27 * param pt: penalty timers list as from penalty_timers_init().
28 * param for_object: arbitrary pointer reference to clear penalty time for,
29 * or NULL to clear all timers. */
30void penalty_timers_clear(struct penalty_timers *pt, void *for_object);
31
32/* Free a struct as returned from penalty_timers_init().
33 * Clear all timers from the list, deallocate the list and set the pointer to NULL.
34 * param pt: pointer-to-pointer which references a struct penalty_timers as returned by
35 * penalty_timers_init(); *pt_p will be set to NULL. */
36void penalty_timers_free(struct penalty_timers **pt_p);