summaryrefslogtreecommitdiff
path: root/cesar/cp2/cco/bw/inc/bw.h
blob: ef7c85320675cc5a0f072a33dacec01694ac7beb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#ifndef cp_cco_inc_bw_h
#define cp_cco_inc_bw_h
/* Cesar project {{{
 *
 * Copyright (C) 2008 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    inc/cp_cco_bw_private.h
 * \brief   « brief description »
 * \ingroup « module »
 *
 * « long description »
 */
#include "lib/set.h"
#include "cp2/cco/bw/bw.h"
#include "cp2/conn/link.h"

#define FORWARD true
#define BACKWARD false

/**
 * Release the schedule after finalising it and sending it.
 * \param  sched  schedule to release
 * \return  \todo fill this
 *
 *  Initialise the new schedule
 */
cp_cco_bw_alloc_t*
cp_cco_bw_release_sched (cp_cco_bw_alloc_t* sched);


/**
 * Function taht will allocate the central beacon
 * \param  ctx  Control Plane Context
 *
 */
void
cp_cco_bw_alloc_central (cp_t *ctx);

/**
 * Function taht will allocate the min_csma
 * \param  ctx  Control Plane Context
 *
 */
void
cp_cco_bw_alloc_mincsma (cp_t *ctx);

/**
 * Function taht will allocate the end_tdma
 * \param  ctx  Control Plane Context
 *
 */
void
cp_cco_bw_alloc_end_tdma (cp_t *ctx);

/**
 * Function taht will allocate the cfpi
 * \param  ctx  Control Plane Context
 *
 */
void
cp_cco_bw_alloc_cfpi (cp_t *ctx);

/**
 * Function that will allocate the proxy beacons
 * \param  ctx  Control Plane Context
 *
 */
void
cp_cco_bw_alloc_proxy (cp_t *ctx);

/**
 * Allocate the discover beacon
 * \param  ctx  Control Plane context
 *
 */
void
cp_cco_bw_alloc_discover (cp_t *ctx);

/**
 * Return the next allocation
 * \param  ctx  Control Plane Context
 * \param  conn  finalised allocation
 * \return  The next allocation
 *
 */
cp_cco_bw_alloc_t*
cp_cco_bw_get_next_alloc_finalised(cp_cco_bw_alloc_t *alloc);

/**
 * Return the first connection of a heap
 * \param  heap  Heap
 * \return  The first connection of the heap
 *
 */
cp_cco_bw_alloc_t*
cp_cco_bw_get_first_alloc_finalised(cp_t *ctx);

/**
 * Return the next allocation
 * \param  ctx  Control Plane Context
 * \param  conn  actual allocation
 * \return  The next allocation
 *
 */
cp_cco_bw_alloc_t*
cp_cco_bw_get_next_alloc_actual(cp_cco_bw_alloc_t *alloc);

/**
 * Return the first connection of a heap
 * \param  heap  Heap
 * \return  The first connection of the heap
 *
 */
cp_cco_bw_alloc_t*
cp_cco_bw_get_first_alloc_actual(cp_t *ctx);

/**
 * Returns the last ble and checks if the end of the free time has been
 * reached
 * \param  first_ble  First ble of the calculation spot
 * \param  last_ble  Last ble of this allocation spot
 * \param  nb_pb  Number of PBs to allocate
 * \param  alloc  allocation before the free time spot
 * \param  next_alloc  next allocation
 * \return  false we have reached the end of the spot before finishing the
 * allocation
 *
 */
bool
cp_cco_bw_get_alloc_ble(cp_link_ble_interval_t **first_ble,
                        cp_link_ble_interval_t **last_ble,
                        u16 nb_pb,
                        cp_cco_bw_alloc_t *alloc,
                        cp_cco_bw_alloc_t *next_alloc);

/**
 * Calculate the best allocation time between 2 BLE
 * \param  first_ble  First BLE
 * \param  last_ble  Last BLE
 * \param  nb_pb  Number of PB to allocate
 * \param  alloc_st  Allocation Start Time
 * \param  alloc_et  Allocation End Time
 * \param  alloc  Previous allocaton
 * \param  next_alloc  Next_allocation
 *
 */
void
cp_cco_bw_calculation_of_alloc_time(cp_link_ble_interval_t *first_ble,
                                    cp_link_ble_interval_t *last_ble,
                                    u16 nb_pb,
                                    u16 *alloc_st,
                                    u16 *alloc_et,
                                    cp_cco_bw_alloc_t *alloc,
                                    cp_cco_bw_alloc_t *next_alloc);

#endif /* cp_cco_bw_private_h */