blob: b0106caf448c71d97158914e8fb4fc64b8b14c00 [file] [log] [blame]
Holger Hans Peter Freytherb8098662013-10-30 14:50:17 +01001/*
2 * TbfTest.cpp
3 *
4 * Copyright (C) 2013 by Holger Hans Peter Freyther
5 *
6 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#include "bts.h"
24#include "tbf.h"
25#include "gprs_debug.h"
Jacob Erlbeck2cbe80b2015-03-25 10:48:52 +010026#include "pcu_utils.h"
Jacob Erlbeckd58b7112015-04-09 19:17:21 +020027#include "gprs_bssgp_pcu.h"
Holger Hans Peter Freytherb8098662013-10-30 14:50:17 +010028
29extern "C" {
Jacob Erlbeckd58b7112015-04-09 19:17:21 +020030#include "pcu_vty.h"
31
Holger Hans Peter Freytherb8098662013-10-30 14:50:17 +010032#include <osmocom/core/application.h>
33#include <osmocom/core/msgb.h>
34#include <osmocom/core/talloc.h>
35#include <osmocom/core/utils.h>
Jacob Erlbeckd58b7112015-04-09 19:17:21 +020036#include <osmocom/vty/vty.h>
Holger Hans Peter Freytherb8098662013-10-30 14:50:17 +010037}
38
Jacob Erlbeckd58b7112015-04-09 19:17:21 +020039#include <errno.h>
40
Holger Hans Peter Freytherb8098662013-10-30 14:50:17 +010041void *tall_pcu_ctx;
42int16_t spoof_mnc = 0, spoof_mcc = 0;
43
Jacob Erlbeck08fe76a2015-02-23 15:10:20 +010044static void check_tbf(gprs_rlcmac_tbf *tbf)
45{
46 OSMO_ASSERT(tbf);
47 OSMO_ASSERT(tbf->m_new_tbf == NULL || tbf->m_new_tbf->m_old_tbf == tbf);
48 OSMO_ASSERT(tbf->m_old_tbf == NULL || tbf->m_old_tbf->m_new_tbf == tbf);
49}
50
Holger Hans Peter Freytherb8098662013-10-30 14:50:17 +010051static void test_tbf_tlli_update()
52{
53 BTS the_bts;
Jacob Erlbeck93990462015-05-15 15:50:43 +020054 GprsMs *ms, *ms_new;
55
Holger Hans Peter Freytherb8098662013-10-30 14:50:17 +010056 the_bts.bts_data()->alloc_algorithm = alloc_algorithm_a;
57 the_bts.bts_data()->trx[0].pdch[2].enable();
58 the_bts.bts_data()->trx[0].pdch[3].enable();
59
60 /*
61 * Make a uplink and downlink allocation
62 */
Daniel Willmann48aa0b02014-07-16 18:54:10 +020063 gprs_rlcmac_tbf *dl_tbf = tbf_alloc_dl_tbf(the_bts.bts_data(),
64 NULL, 0,
Holger Hans Peter Freytherb8098662013-10-30 14:50:17 +010065 0, 0, 0);
66 dl_tbf->update_tlli(0x2342);
Jacob Erlbeckbe0cbc12015-05-18 14:35:11 +020067 dl_tbf->update_ms(0x2342, GPRS_RLCMAC_DL_TBF);
Holger Hans Peter Freytherb8098662013-10-30 14:50:17 +010068 dl_tbf->ta = 4;
69 the_bts.timing_advance()->remember(0x2342, dl_tbf->ta);
70
Daniel Willmann48aa0b02014-07-16 18:54:10 +020071 gprs_rlcmac_tbf *ul_tbf = tbf_alloc_ul_tbf(the_bts.bts_data(),
Jacob Erlbeck801d6fe2015-05-04 09:44:19 +020072 dl_tbf, 0,
Holger Hans Peter Freytherb8098662013-10-30 14:50:17 +010073 0, 0, 0);
74 ul_tbf->update_tlli(0x2342);
Jacob Erlbeck0e50ce62015-05-21 16:58:22 +020075 ul_tbf->update_ms(0x2342, GPRS_RLCMAC_UL_TBF);
Holger Hans Peter Freytherb8098662013-10-30 14:50:17 +010076
Jacob Erlbeck93990462015-05-15 15:50:43 +020077 ms = the_bts.ms_by_tlli(0x2342);
Holger Hans Peter Freytherb8098662013-10-30 14:50:17 +010078
Jacob Erlbeck93990462015-05-15 15:50:43 +020079 OSMO_ASSERT(ms != NULL);
80 OSMO_ASSERT(ms->dl_tbf() == dl_tbf);
81 OSMO_ASSERT(ms->ul_tbf() == ul_tbf);
Holger Hans Peter Freytherb8098662013-10-30 14:50:17 +010082
83 /*
84 * Now check.. that DL changes and that the timing advance
85 * has changed.
86 */
87 dl_tbf->update_tlli(0x4232);
Jacob Erlbeck0e50ce62015-05-21 16:58:22 +020088 dl_tbf->update_ms(0x4232, GPRS_RLCMAC_DL_TBF);
Holger Hans Peter Freytherb8098662013-10-30 14:50:17 +010089
Jacob Erlbeck93990462015-05-15 15:50:43 +020090 /* It is still there, since the new TLLI has not been used for UL yet */
91 ms_new = the_bts.ms_by_tlli(0x2342);
92 OSMO_ASSERT(ms == ms_new);
93
94 ms_new = the_bts.ms_by_tlli(0x4232);
95 OSMO_ASSERT(ms == ms_new);
96 OSMO_ASSERT(ms->dl_tbf() == dl_tbf);
97 OSMO_ASSERT(ms->ul_tbf() == ul_tbf);
98
99 /* Now use the new TLLI for UL */
Jacob Erlbeck0e50ce62015-05-21 16:58:22 +0200100 ul_tbf->update_ms(0x4232, GPRS_RLCMAC_UL_TBF);
Jacob Erlbeck93990462015-05-15 15:50:43 +0200101 ms_new = the_bts.ms_by_tlli(0x2342);
102 OSMO_ASSERT(ms_new == NULL);
Holger Hans Peter Freytherbc1626e2013-10-30 19:50:49 +0100103
104 OSMO_ASSERT(the_bts.timing_advance()->recall(0x4232) == 4);
Holger Hans Peter Freytherb8098662013-10-30 14:50:17 +0100105}
106
Daniel Willmann510d7d32014-08-15 18:19:41 +0200107static uint8_t llc_data[200];
108
109int pcu_sock_send(struct msgb *msg)
110{
111 return 0;
112}
113
Jacob Erlbecka3e45092015-03-25 09:11:24 +0100114static void setup_bts(BTS *the_bts, uint8_t ts_no)
115{
116 gprs_rlcmac_bts *bts;
117 gprs_rlcmac_trx *trx;
118
119 bts = the_bts->bts_data();
120 bts->alloc_algorithm = alloc_algorithm_a;
121 trx = &bts->trx[0];
122
123 trx->pdch[ts_no].enable();
124}
125
126static gprs_rlcmac_dl_tbf *create_dl_tbf(BTS *the_bts, uint8_t ms_class,
127 uint8_t *trx_no_)
128{
129 gprs_rlcmac_bts *bts;
130 int tfi;
131 uint8_t trx_no;
132
133 gprs_rlcmac_dl_tbf *dl_tbf;
134
135 bts = the_bts->bts_data();
136
137 tfi = the_bts->tfi_find_free(GPRS_RLCMAC_DL_TBF, &trx_no, -1);
138 OSMO_ASSERT(tfi >= 0);
139 dl_tbf = tbf_alloc_dl_tbf(bts, NULL, tfi, trx_no, ms_class, 1);
140 check_tbf(dl_tbf);
141
142 /* "Establish" the DL TBF */
143 dl_tbf->dl_ass_state = GPRS_RLCMAC_DL_ASS_SEND_ASS;
144 dl_tbf->set_state(GPRS_RLCMAC_FLOW);
145 dl_tbf->m_wait_confirm = 0;
146 dl_tbf->set_new_tbf(dl_tbf);
147 check_tbf(dl_tbf);
148
149 *trx_no_ = trx_no;
150
151 return dl_tbf;
152}
153
Jacob Erlbeck2493c662015-03-25 10:05:34 +0100154static void send_rlc_block(struct gprs_rlcmac_bts *bts,
155 uint8_t trx_no, uint8_t ts_no, uint16_t arfcn,
156 uint32_t *fn, uint8_t *block_nr)
157{
158 gprs_rlcmac_rcv_rts_block(bts, trx_no, ts_no, 0, *fn, *block_nr);
159 *fn += 4;
160 if ((*fn % 13) == 12)
161 *fn += 1;
162 *block_nr += 1;
163}
164
Jacob Erlbeck5e9f40d2015-02-23 14:26:59 +0100165enum test_tbf_final_ack_mode {
166 TEST_MODE_STANDARD,
167 TEST_MODE_REVERSE_FREE
168};
169
170static void test_tbf_final_ack(enum test_tbf_final_ack_mode test_mode)
Daniel Willmann510d7d32014-08-15 18:19:41 +0200171{
172 BTS the_bts;
173 gprs_rlcmac_bts *bts;
Jacob Erlbecka3e45092015-03-25 09:11:24 +0100174 uint8_t ts_no = 4;
175 unsigned i;
Daniel Willmann510d7d32014-08-15 18:19:41 +0200176 uint8_t ms_class = 45;
177 uint32_t fn;
Jacob Erlbeck2493c662015-03-25 10:05:34 +0100178 uint8_t block_nr;
Jacob Erlbecka3e45092015-03-25 09:11:24 +0100179 uint8_t trx_no;
Daniel Willmann510d7d32014-08-15 18:19:41 +0200180
181 uint8_t rbb[64/8];
182
Daniel Willmann510d7d32014-08-15 18:19:41 +0200183 gprs_rlcmac_dl_tbf *dl_tbf;
184 gprs_rlcmac_tbf *new_tbf;
185
186 bts = the_bts.bts_data();
Daniel Willmann510d7d32014-08-15 18:19:41 +0200187
Jacob Erlbecka3e45092015-03-25 09:11:24 +0100188 setup_bts(&the_bts, ts_no);
189 dl_tbf = create_dl_tbf(&the_bts, ms_class, &trx_no);
Daniel Willmann510d7d32014-08-15 18:19:41 +0200190
191 for (i = 0; i < sizeof(llc_data); i++)
192 llc_data[i] = i%256;
193
Jacob Erlbeck2493c662015-03-25 10:05:34 +0100194 /* Schedule two LLC frames */
Daniel Willmann0f58af62014-09-19 11:57:21 +0200195 dl_tbf->append_data(ms_class, 1000, llc_data, sizeof(llc_data));
196 dl_tbf->append_data(ms_class, 1000, llc_data, sizeof(llc_data));
Daniel Willmann510d7d32014-08-15 18:19:41 +0200197
198
Jacob Erlbeck2493c662015-03-25 10:05:34 +0100199 /* Send only a few RLC/MAC blocks */
Daniel Willmann510d7d32014-08-15 18:19:41 +0200200 fn = 0;
Jacob Erlbeck2493c662015-03-25 10:05:34 +0100201 block_nr = 0;
202 while (block_nr < 3) {
Daniel Willmann510d7d32014-08-15 18:19:41 +0200203 /* Request to send one block */
Jacob Erlbeck2493c662015-03-25 10:05:34 +0100204 send_rlc_block(bts, trx_no, ts_no, 0, &fn, &block_nr);
Daniel Willmann510d7d32014-08-15 18:19:41 +0200205 }
Jacob Erlbeck2493c662015-03-25 10:05:34 +0100206 OSMO_ASSERT(dl_tbf->have_data());
207 OSMO_ASSERT(dl_tbf->state_is(GPRS_RLCMAC_FLOW));
Daniel Willmann510d7d32014-08-15 18:19:41 +0200208
209 /* Queue a final ACK */
210 memset(rbb, 0, sizeof(rbb));
211 /* Receive a final ACK */
212 dl_tbf->rcvd_dl_ack(1, 1, rbb);
213
214 /* Clean up and ensure tbfs are in the correct state */
215 OSMO_ASSERT(dl_tbf->state_is(GPRS_RLCMAC_WAIT_RELEASE));
216 new_tbf = dl_tbf->new_tbf();
Jacob Erlbeck08fe76a2015-02-23 15:10:20 +0100217 check_tbf(new_tbf);
Daniel Willmann510d7d32014-08-15 18:19:41 +0200218 OSMO_ASSERT(new_tbf != dl_tbf);
219 OSMO_ASSERT(new_tbf->tfi() == 1);
Jacob Erlbeck08fe76a2015-02-23 15:10:20 +0100220 check_tbf(dl_tbf);
Daniel Willmann510d7d32014-08-15 18:19:41 +0200221 dl_tbf->dl_ass_state = GPRS_RLCMAC_DL_ASS_NONE;
Jacob Erlbeck5e9f40d2015-02-23 14:26:59 +0100222 if (test_mode == TEST_MODE_REVERSE_FREE) {
223 tbf_free(new_tbf);
Jacob Erlbeck08fe76a2015-02-23 15:10:20 +0100224 OSMO_ASSERT(dl_tbf->m_new_tbf != new_tbf);
225 check_tbf(dl_tbf);
Jacob Erlbeck5e9f40d2015-02-23 14:26:59 +0100226 tbf_free(dl_tbf);
227 } else {
228 tbf_free(dl_tbf);
229 OSMO_ASSERT(new_tbf->m_new_tbf != dl_tbf);
Jacob Erlbeck08fe76a2015-02-23 15:10:20 +0100230 check_tbf(new_tbf);
Jacob Erlbeck5e9f40d2015-02-23 14:26:59 +0100231 tbf_free(new_tbf);
232 }
Daniel Willmann510d7d32014-08-15 18:19:41 +0200233}
234
Jacob Erlbeck2cbe80b2015-03-25 10:48:52 +0100235static void test_tbf_delayed_release()
236{
237 BTS the_bts;
238 gprs_rlcmac_bts *bts;
239 uint8_t ts_no = 4;
240 unsigned i;
241 uint8_t ms_class = 45;
242 uint32_t fn = 0;
243 uint8_t block_nr = 0;
244 uint8_t trx_no;
245
246 uint8_t rbb[64/8];
247
248 gprs_rlcmac_dl_tbf *dl_tbf;
249
250 printf("=== start %s ===\n", __func__);
251
252 bts = the_bts.bts_data();
253
254 setup_bts(&the_bts, ts_no);
255 bts->dl_tbf_idle_msec = 200;
256
257 dl_tbf = create_dl_tbf(&the_bts, ms_class, &trx_no);
258
259 for (i = 0; i < sizeof(llc_data); i++)
260 llc_data[i] = i%256;
261
262 OSMO_ASSERT(dl_tbf->state_is(GPRS_RLCMAC_FLOW));
263
264 /* Schedule two LLC frames */
265 dl_tbf->append_data(ms_class, 1000, llc_data, sizeof(llc_data));
266 dl_tbf->append_data(ms_class, 1000, llc_data, sizeof(llc_data));
267
268 OSMO_ASSERT(dl_tbf->state_is(GPRS_RLCMAC_FLOW));
269
270 /* Drain the queue */
271 while (dl_tbf->have_data())
272 /* Request to send one RLC/MAC block */
273 send_rlc_block(bts, trx_no, ts_no, 0, &fn, &block_nr);
274
275 OSMO_ASSERT(dl_tbf->state_is(GPRS_RLCMAC_FLOW));
276
277 /* ACK all blocks */
278 memset(rbb, 0xff, sizeof(rbb));
279 /* Receive an ACK */
280 dl_tbf->rcvd_dl_ack(0, dl_tbf->m_window.v_s(), rbb);
281 OSMO_ASSERT(dl_tbf->m_window.window_empty());
282
283 /* Force sending of a single block containing an LLC dummy command */
284 send_rlc_block(bts, trx_no, ts_no, 0, &fn, &block_nr);
285
286 /* Receive an ACK */
287 dl_tbf->rcvd_dl_ack(0, dl_tbf->m_window.v_s(), rbb);
288 OSMO_ASSERT(dl_tbf->m_window.window_empty());
289
290 /* Timeout (make sure fn % 52 remains valid) */
291 fn += 52 * ((msecs_to_frames(bts->dl_tbf_idle_msec + 100) + 51)/ 52);
292 send_rlc_block(bts, trx_no, ts_no, 0, &fn, &block_nr);
293
294 OSMO_ASSERT(dl_tbf->state_is(GPRS_RLCMAC_FINISHED));
295
296 /* Receive a final ACK */
297 dl_tbf->rcvd_dl_ack(1, dl_tbf->m_window.v_s(), rbb);
298
299 /* Clean up and ensure tbfs are in the correct state */
300 OSMO_ASSERT(dl_tbf->state_is(GPRS_RLCMAC_WAIT_RELEASE));
301 OSMO_ASSERT(dl_tbf->new_tbf() == dl_tbf);
302 dl_tbf->dl_ass_state = GPRS_RLCMAC_DL_ASS_NONE;
303 check_tbf(dl_tbf);
304 tbf_free(dl_tbf);
305 printf("=== end %s ===\n", __func__);
306}
307
Jacob Erlbeckb0e5eaf2015-05-21 11:07:16 +0200308static void test_tbf_imsi()
309{
310 BTS the_bts;
311 uint8_t ts_no = 4;
312 uint8_t ms_class = 45;
313 uint8_t trx_no;
314 GprsMs *ms1, *ms2;
315
316 gprs_rlcmac_dl_tbf *dl_tbf[2];
317
318 printf("=== start %s ===\n", __func__);
319
320 setup_bts(&the_bts, ts_no);
321
322 dl_tbf[0] = create_dl_tbf(&the_bts, ms_class, &trx_no);
323 dl_tbf[1] = create_dl_tbf(&the_bts, ms_class, &trx_no);
324
325 dl_tbf[0]->update_ms(0xf1000001, GPRS_RLCMAC_DL_TBF);
326 dl_tbf[1]->update_ms(0xf1000002, GPRS_RLCMAC_DL_TBF);
327
328 dl_tbf[0]->assign_imsi("001001000000001");
329 ms1 = the_bts.ms_store().get_ms(0, 0, "001001000000001");
Jacob Erlbeck7b9f8252015-05-21 11:07:53 +0200330 OSMO_ASSERT(ms1 != NULL);
Jacob Erlbeckb0e5eaf2015-05-21 11:07:16 +0200331 ms2 = the_bts.ms_store().get_ms(0xf1000001);
332 OSMO_ASSERT(ms2 != NULL);
333 OSMO_ASSERT(strcmp(ms2->imsi(), "001001000000001") == 0);
Jacob Erlbeck7b9f8252015-05-21 11:07:53 +0200334 OSMO_ASSERT(ms1 == ms2);
Jacob Erlbeckb0e5eaf2015-05-21 11:07:16 +0200335
336 /* change the IMSI on TBF 0 */
337 dl_tbf[0]->assign_imsi("001001000000002");
338 ms1 = the_bts.ms_store().get_ms(0, 0, "001001000000001");
339 OSMO_ASSERT(ms1 == NULL);
340 ms1 = the_bts.ms_store().get_ms(0, 0, "001001000000002");
Jacob Erlbeck7b9f8252015-05-21 11:07:53 +0200341 OSMO_ASSERT(ms1 != NULL);
Jacob Erlbeckb0e5eaf2015-05-21 11:07:16 +0200342 OSMO_ASSERT(strcmp(ms2->imsi(), "001001000000002") == 0);
Jacob Erlbeck7b9f8252015-05-21 11:07:53 +0200343 OSMO_ASSERT(ms1 == ms2);
Jacob Erlbeckb0e5eaf2015-05-21 11:07:16 +0200344
345 /* use the same IMSI on TBF 2 */
346 dl_tbf[1]->assign_imsi("001001000000002");
347 ms1 = the_bts.ms_store().get_ms(0, 0, "001001000000002");
Jacob Erlbeck7b9f8252015-05-21 11:07:53 +0200348 OSMO_ASSERT(ms1 != NULL);
Jacob Erlbeckb0e5eaf2015-05-21 11:07:16 +0200349 OSMO_ASSERT(ms1 != ms2);
Jacob Erlbeck7b9f8252015-05-21 11:07:53 +0200350 OSMO_ASSERT(strcmp(ms1->imsi(), "001001000000002") == 0);
351 OSMO_ASSERT(strcmp(ms2->imsi(), "") == 0);
Jacob Erlbeckb0e5eaf2015-05-21 11:07:16 +0200352
353 tbf_free(dl_tbf[1]);
354 ms1 = the_bts.ms_store().get_ms(0, 0, "001001000000002");
355 OSMO_ASSERT(ms1 == NULL);
356
357 tbf_free(dl_tbf[0]);
358 printf("=== end %s ===\n", __func__);
359}
360
Jacob Erlbeckd58b7112015-04-09 19:17:21 +0200361static void test_tbf_exhaustion()
362{
363 BTS the_bts;
364 gprs_rlcmac_bts *bts;
365 unsigned i;
366 uint8_t ts_no = 4;
367 uint8_t ms_class = 45;
368 int rc = 0;
369
370 uint8_t buf[256] = {0};
371
372 printf("=== start %s ===\n", __func__);
373
374 bts = the_bts.bts_data();
375 setup_bts(&the_bts, ts_no);
376 gprs_bssgp_create_and_connect(bts, 33001, 0, 33001,
377 1234, 1234, 1234, 1, 1, 0, 0, 0);
378
379 for (i = 0; i < 1024; i++) {
380 uint32_t tlli = 0xc0000000 + i;
381 char imsi[16] = {0};
382 unsigned delay_csec = 1000;
383
Jacob Erlbeck9a2845d2015-05-21 12:06:58 +0200384 snprintf(imsi, sizeof(imsi), "001001%09d", i);
Jacob Erlbeckd58b7112015-04-09 19:17:21 +0200385
Jacob Erlbeck93990462015-05-15 15:50:43 +0200386 rc = gprs_rlcmac_dl_tbf::handle(bts, tlli, 0, imsi, ms_class,
Jacob Erlbeckd58b7112015-04-09 19:17:21 +0200387 delay_csec, buf, sizeof(buf));
388
389 if (rc < 0)
390 break;
391 }
392
393 OSMO_ASSERT(rc == -EBUSY);
394 printf("=== end %s ===\n", __func__);
395
396 gprs_bssgp_destroy();
397}
398
Daniel Willmann341689d2014-06-11 18:33:14 +0200399static const struct log_info_cat default_categories[] = {
400 {"DCSN1", "\033[1;31m", "Concrete Syntax Notation One (CSN1)", LOGL_INFO, 0},
401 {"DL1IF", "\033[1;32m", "GPRS PCU L1 interface (L1IF)", LOGL_DEBUG, 1},
402 {"DRLCMAC", "\033[0;33m", "GPRS RLC/MAC layer (RLCMAC)", LOGL_DEBUG, 1},
403 {"DRLCMACDATA", "\033[0;33m", "GPRS RLC/MAC layer Data (RLCMAC)", LOGL_DEBUG, 1},
404 {"DRLCMACDL", "\033[1;33m", "GPRS RLC/MAC layer Downlink (RLCMAC)", LOGL_DEBUG, 1},
405 {"DRLCMACUL", "\033[1;36m", "GPRS RLC/MAC layer Uplink (RLCMAC)", LOGL_DEBUG, 1},
406 {"DRLCMACSCHED", "\033[0;36m", "GPRS RLC/MAC layer Scheduling (RLCMAC)", LOGL_DEBUG, 1},
407 {"DRLCMACMEAS", "\033[1;31m", "GPRS RLC/MAC layer Measurements (RLCMAC)", LOGL_INFO, 1},
408 {"DBSSGP","\033[1;34m", "GPRS BSS Gateway Protocol (BSSGP)", LOGL_INFO , 1},
409 {"DPCU", "\033[1;35m", "GPRS Packet Control Unit (PCU)", LOGL_NOTICE, 1},
410};
411
412static int filter_fn(const struct log_context *ctx,
413 struct log_target *tar)
414{
415 return 1;
416}
417
418const struct log_info debug_log_info = {
419 filter_fn,
420 (struct log_info_cat*)default_categories,
421 ARRAY_SIZE(default_categories),
422};
423
Holger Hans Peter Freytherb8098662013-10-30 14:50:17 +0100424int main(int argc, char **argv)
425{
Jacob Erlbeckd58b7112015-04-09 19:17:21 +0200426 struct vty_app_info pcu_vty_info = {0};
427
Holger Hans Peter Freytherb8098662013-10-30 14:50:17 +0100428 tall_pcu_ctx = talloc_named_const(NULL, 1, "moiji-mobile TbfTest context");
429 if (!tall_pcu_ctx)
430 abort();
431
432 msgb_set_talloc_ctx(tall_pcu_ctx);
Daniel Willmann341689d2014-06-11 18:33:14 +0200433 osmo_init_logging(&debug_log_info);
Holger Hans Peter Freytherb8098662013-10-30 14:50:17 +0100434 log_set_use_color(osmo_stderr_target, 0);
435 log_set_print_filename(osmo_stderr_target, 0);
Jacob Erlbeckd58b7112015-04-09 19:17:21 +0200436 bssgp_set_log_ss(DBSSGP);
437
438 vty_init(&pcu_vty_info);
439 pcu_vty_init(&debug_log_info);
Holger Hans Peter Freytherb8098662013-10-30 14:50:17 +0100440
441 test_tbf_tlli_update();
Jacob Erlbeck5e9f40d2015-02-23 14:26:59 +0100442 test_tbf_final_ack(TEST_MODE_STANDARD);
443 test_tbf_final_ack(TEST_MODE_REVERSE_FREE);
Jacob Erlbeck2cbe80b2015-03-25 10:48:52 +0100444 test_tbf_delayed_release();
Jacob Erlbeckb0e5eaf2015-05-21 11:07:16 +0200445 test_tbf_imsi();
Jacob Erlbeckd58b7112015-04-09 19:17:21 +0200446 test_tbf_exhaustion();
Jacob Erlbeck67c38502015-05-11 10:32:40 +0200447
448 if (getenv("TALLOC_REPORT_FULL"))
449 talloc_report_full(tall_pcu_ctx, stderr);
Holger Hans Peter Freytherb8098662013-10-30 14:50:17 +0100450 return EXIT_SUCCESS;
451}
452
453/*
454 * stubs that should not be reached
455 */
456extern "C" {
457void l1if_pdch_req() { abort(); }
458void l1if_connect_pdch() { abort(); }
459void l1if_close_pdch() { abort(); }
460void l1if_open_pdch() { abort(); }
461}