Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 1 | /* |
| 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 Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 26 | #include "pcu_utils.h" |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 27 | #include "gprs_bssgp_pcu.h" |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 28 | |
| 29 | extern "C" { |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 30 | #include "pcu_vty.h" |
| 31 | |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 32 | #include <osmocom/core/application.h> |
| 33 | #include <osmocom/core/msgb.h> |
| 34 | #include <osmocom/core/talloc.h> |
| 35 | #include <osmocom/core/utils.h> |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 36 | #include <osmocom/vty/vty.h> |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 37 | } |
| 38 | |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 39 | #include <errno.h> |
| 40 | |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 41 | void *tall_pcu_ctx; |
| 42 | int16_t spoof_mnc = 0, spoof_mcc = 0; |
| 43 | |
Jacob Erlbeck | 08fe76a | 2015-02-23 15:10:20 +0100 | [diff] [blame] | 44 | static 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 Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 51 | static void test_tbf_tlli_update() |
| 52 | { |
| 53 | BTS the_bts; |
Jacob Erlbeck | 9399046 | 2015-05-15 15:50:43 +0200 | [diff] [blame] | 54 | GprsMs *ms, *ms_new; |
| 55 | |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 56 | 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 Willmann | 48aa0b0 | 2014-07-16 18:54:10 +0200 | [diff] [blame] | 63 | gprs_rlcmac_tbf *dl_tbf = tbf_alloc_dl_tbf(the_bts.bts_data(), |
| 64 | NULL, 0, |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 65 | 0, 0, 0); |
| 66 | dl_tbf->update_tlli(0x2342); |
Jacob Erlbeck | be0cbc1 | 2015-05-18 14:35:11 +0200 | [diff] [blame] | 67 | dl_tbf->update_ms(0x2342, GPRS_RLCMAC_DL_TBF); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 68 | dl_tbf->ta = 4; |
| 69 | the_bts.timing_advance()->remember(0x2342, dl_tbf->ta); |
| 70 | |
Daniel Willmann | 48aa0b0 | 2014-07-16 18:54:10 +0200 | [diff] [blame] | 71 | gprs_rlcmac_tbf *ul_tbf = tbf_alloc_ul_tbf(the_bts.bts_data(), |
Jacob Erlbeck | 801d6fe | 2015-05-04 09:44:19 +0200 | [diff] [blame] | 72 | dl_tbf, 0, |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 73 | 0, 0, 0); |
| 74 | ul_tbf->update_tlli(0x2342); |
Jacob Erlbeck | 0e50ce6 | 2015-05-21 16:58:22 +0200 | [diff] [blame^] | 75 | ul_tbf->update_ms(0x2342, GPRS_RLCMAC_UL_TBF); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 76 | |
Jacob Erlbeck | 9399046 | 2015-05-15 15:50:43 +0200 | [diff] [blame] | 77 | ms = the_bts.ms_by_tlli(0x2342); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 78 | |
Jacob Erlbeck | 9399046 | 2015-05-15 15:50:43 +0200 | [diff] [blame] | 79 | OSMO_ASSERT(ms != NULL); |
| 80 | OSMO_ASSERT(ms->dl_tbf() == dl_tbf); |
| 81 | OSMO_ASSERT(ms->ul_tbf() == ul_tbf); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 82 | |
| 83 | /* |
| 84 | * Now check.. that DL changes and that the timing advance |
| 85 | * has changed. |
| 86 | */ |
| 87 | dl_tbf->update_tlli(0x4232); |
Jacob Erlbeck | 0e50ce6 | 2015-05-21 16:58:22 +0200 | [diff] [blame^] | 88 | dl_tbf->update_ms(0x4232, GPRS_RLCMAC_DL_TBF); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 89 | |
Jacob Erlbeck | 9399046 | 2015-05-15 15:50:43 +0200 | [diff] [blame] | 90 | /* 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 Erlbeck | 0e50ce6 | 2015-05-21 16:58:22 +0200 | [diff] [blame^] | 100 | ul_tbf->update_ms(0x4232, GPRS_RLCMAC_UL_TBF); |
Jacob Erlbeck | 9399046 | 2015-05-15 15:50:43 +0200 | [diff] [blame] | 101 | ms_new = the_bts.ms_by_tlli(0x2342); |
| 102 | OSMO_ASSERT(ms_new == NULL); |
Holger Hans Peter Freyther | bc1626e | 2013-10-30 19:50:49 +0100 | [diff] [blame] | 103 | |
| 104 | OSMO_ASSERT(the_bts.timing_advance()->recall(0x4232) == 4); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 105 | } |
| 106 | |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 107 | static uint8_t llc_data[200]; |
| 108 | |
| 109 | int pcu_sock_send(struct msgb *msg) |
| 110 | { |
| 111 | return 0; |
| 112 | } |
| 113 | |
Jacob Erlbeck | a3e4509 | 2015-03-25 09:11:24 +0100 | [diff] [blame] | 114 | static 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 | |
| 126 | static 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 Erlbeck | 2493c66 | 2015-03-25 10:05:34 +0100 | [diff] [blame] | 154 | static 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 Erlbeck | 5e9f40d | 2015-02-23 14:26:59 +0100 | [diff] [blame] | 165 | enum test_tbf_final_ack_mode { |
| 166 | TEST_MODE_STANDARD, |
| 167 | TEST_MODE_REVERSE_FREE |
| 168 | }; |
| 169 | |
| 170 | static void test_tbf_final_ack(enum test_tbf_final_ack_mode test_mode) |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 171 | { |
| 172 | BTS the_bts; |
| 173 | gprs_rlcmac_bts *bts; |
Jacob Erlbeck | a3e4509 | 2015-03-25 09:11:24 +0100 | [diff] [blame] | 174 | uint8_t ts_no = 4; |
| 175 | unsigned i; |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 176 | uint8_t ms_class = 45; |
| 177 | uint32_t fn; |
Jacob Erlbeck | 2493c66 | 2015-03-25 10:05:34 +0100 | [diff] [blame] | 178 | uint8_t block_nr; |
Jacob Erlbeck | a3e4509 | 2015-03-25 09:11:24 +0100 | [diff] [blame] | 179 | uint8_t trx_no; |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 180 | |
| 181 | uint8_t rbb[64/8]; |
| 182 | |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 183 | gprs_rlcmac_dl_tbf *dl_tbf; |
| 184 | gprs_rlcmac_tbf *new_tbf; |
| 185 | |
| 186 | bts = the_bts.bts_data(); |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 187 | |
Jacob Erlbeck | a3e4509 | 2015-03-25 09:11:24 +0100 | [diff] [blame] | 188 | setup_bts(&the_bts, ts_no); |
| 189 | dl_tbf = create_dl_tbf(&the_bts, ms_class, &trx_no); |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 190 | |
| 191 | for (i = 0; i < sizeof(llc_data); i++) |
| 192 | llc_data[i] = i%256; |
| 193 | |
Jacob Erlbeck | 2493c66 | 2015-03-25 10:05:34 +0100 | [diff] [blame] | 194 | /* Schedule two LLC frames */ |
Daniel Willmann | 0f58af6 | 2014-09-19 11:57:21 +0200 | [diff] [blame] | 195 | 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 Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 197 | |
| 198 | |
Jacob Erlbeck | 2493c66 | 2015-03-25 10:05:34 +0100 | [diff] [blame] | 199 | /* Send only a few RLC/MAC blocks */ |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 200 | fn = 0; |
Jacob Erlbeck | 2493c66 | 2015-03-25 10:05:34 +0100 | [diff] [blame] | 201 | block_nr = 0; |
| 202 | while (block_nr < 3) { |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 203 | /* Request to send one block */ |
Jacob Erlbeck | 2493c66 | 2015-03-25 10:05:34 +0100 | [diff] [blame] | 204 | send_rlc_block(bts, trx_no, ts_no, 0, &fn, &block_nr); |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 205 | } |
Jacob Erlbeck | 2493c66 | 2015-03-25 10:05:34 +0100 | [diff] [blame] | 206 | OSMO_ASSERT(dl_tbf->have_data()); |
| 207 | OSMO_ASSERT(dl_tbf->state_is(GPRS_RLCMAC_FLOW)); |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 208 | |
| 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 Erlbeck | 08fe76a | 2015-02-23 15:10:20 +0100 | [diff] [blame] | 217 | check_tbf(new_tbf); |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 218 | OSMO_ASSERT(new_tbf != dl_tbf); |
| 219 | OSMO_ASSERT(new_tbf->tfi() == 1); |
Jacob Erlbeck | 08fe76a | 2015-02-23 15:10:20 +0100 | [diff] [blame] | 220 | check_tbf(dl_tbf); |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 221 | dl_tbf->dl_ass_state = GPRS_RLCMAC_DL_ASS_NONE; |
Jacob Erlbeck | 5e9f40d | 2015-02-23 14:26:59 +0100 | [diff] [blame] | 222 | if (test_mode == TEST_MODE_REVERSE_FREE) { |
| 223 | tbf_free(new_tbf); |
Jacob Erlbeck | 08fe76a | 2015-02-23 15:10:20 +0100 | [diff] [blame] | 224 | OSMO_ASSERT(dl_tbf->m_new_tbf != new_tbf); |
| 225 | check_tbf(dl_tbf); |
Jacob Erlbeck | 5e9f40d | 2015-02-23 14:26:59 +0100 | [diff] [blame] | 226 | tbf_free(dl_tbf); |
| 227 | } else { |
| 228 | tbf_free(dl_tbf); |
| 229 | OSMO_ASSERT(new_tbf->m_new_tbf != dl_tbf); |
Jacob Erlbeck | 08fe76a | 2015-02-23 15:10:20 +0100 | [diff] [blame] | 230 | check_tbf(new_tbf); |
Jacob Erlbeck | 5e9f40d | 2015-02-23 14:26:59 +0100 | [diff] [blame] | 231 | tbf_free(new_tbf); |
| 232 | } |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 233 | } |
| 234 | |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 235 | static 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 Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 308 | static void test_tbf_exhaustion() |
| 309 | { |
| 310 | BTS the_bts; |
| 311 | gprs_rlcmac_bts *bts; |
| 312 | unsigned i; |
| 313 | uint8_t ts_no = 4; |
| 314 | uint8_t ms_class = 45; |
| 315 | int rc = 0; |
| 316 | |
| 317 | uint8_t buf[256] = {0}; |
| 318 | |
| 319 | printf("=== start %s ===\n", __func__); |
| 320 | |
| 321 | bts = the_bts.bts_data(); |
| 322 | setup_bts(&the_bts, ts_no); |
| 323 | gprs_bssgp_create_and_connect(bts, 33001, 0, 33001, |
| 324 | 1234, 1234, 1234, 1, 1, 0, 0, 0); |
| 325 | |
| 326 | for (i = 0; i < 1024; i++) { |
| 327 | uint32_t tlli = 0xc0000000 + i; |
| 328 | char imsi[16] = {0}; |
| 329 | unsigned delay_csec = 1000; |
| 330 | |
| 331 | snprintf(imsi, sizeof(imsi)-1, "001001%9d", i); |
| 332 | |
Jacob Erlbeck | 9399046 | 2015-05-15 15:50:43 +0200 | [diff] [blame] | 333 | rc = gprs_rlcmac_dl_tbf::handle(bts, tlli, 0, imsi, ms_class, |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 334 | delay_csec, buf, sizeof(buf)); |
| 335 | |
| 336 | if (rc < 0) |
| 337 | break; |
| 338 | } |
| 339 | |
| 340 | OSMO_ASSERT(rc == -EBUSY); |
| 341 | printf("=== end %s ===\n", __func__); |
| 342 | |
| 343 | gprs_bssgp_destroy(); |
| 344 | } |
| 345 | |
Daniel Willmann | 341689d | 2014-06-11 18:33:14 +0200 | [diff] [blame] | 346 | static const struct log_info_cat default_categories[] = { |
| 347 | {"DCSN1", "\033[1;31m", "Concrete Syntax Notation One (CSN1)", LOGL_INFO, 0}, |
| 348 | {"DL1IF", "\033[1;32m", "GPRS PCU L1 interface (L1IF)", LOGL_DEBUG, 1}, |
| 349 | {"DRLCMAC", "\033[0;33m", "GPRS RLC/MAC layer (RLCMAC)", LOGL_DEBUG, 1}, |
| 350 | {"DRLCMACDATA", "\033[0;33m", "GPRS RLC/MAC layer Data (RLCMAC)", LOGL_DEBUG, 1}, |
| 351 | {"DRLCMACDL", "\033[1;33m", "GPRS RLC/MAC layer Downlink (RLCMAC)", LOGL_DEBUG, 1}, |
| 352 | {"DRLCMACUL", "\033[1;36m", "GPRS RLC/MAC layer Uplink (RLCMAC)", LOGL_DEBUG, 1}, |
| 353 | {"DRLCMACSCHED", "\033[0;36m", "GPRS RLC/MAC layer Scheduling (RLCMAC)", LOGL_DEBUG, 1}, |
| 354 | {"DRLCMACMEAS", "\033[1;31m", "GPRS RLC/MAC layer Measurements (RLCMAC)", LOGL_INFO, 1}, |
| 355 | {"DBSSGP","\033[1;34m", "GPRS BSS Gateway Protocol (BSSGP)", LOGL_INFO , 1}, |
| 356 | {"DPCU", "\033[1;35m", "GPRS Packet Control Unit (PCU)", LOGL_NOTICE, 1}, |
| 357 | }; |
| 358 | |
| 359 | static int filter_fn(const struct log_context *ctx, |
| 360 | struct log_target *tar) |
| 361 | { |
| 362 | return 1; |
| 363 | } |
| 364 | |
| 365 | const struct log_info debug_log_info = { |
| 366 | filter_fn, |
| 367 | (struct log_info_cat*)default_categories, |
| 368 | ARRAY_SIZE(default_categories), |
| 369 | }; |
| 370 | |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 371 | int main(int argc, char **argv) |
| 372 | { |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 373 | struct vty_app_info pcu_vty_info = {0}; |
| 374 | |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 375 | tall_pcu_ctx = talloc_named_const(NULL, 1, "moiji-mobile TbfTest context"); |
| 376 | if (!tall_pcu_ctx) |
| 377 | abort(); |
| 378 | |
| 379 | msgb_set_talloc_ctx(tall_pcu_ctx); |
Daniel Willmann | 341689d | 2014-06-11 18:33:14 +0200 | [diff] [blame] | 380 | osmo_init_logging(&debug_log_info); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 381 | log_set_use_color(osmo_stderr_target, 0); |
| 382 | log_set_print_filename(osmo_stderr_target, 0); |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 383 | bssgp_set_log_ss(DBSSGP); |
| 384 | |
| 385 | vty_init(&pcu_vty_info); |
| 386 | pcu_vty_init(&debug_log_info); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 387 | |
| 388 | test_tbf_tlli_update(); |
Jacob Erlbeck | 5e9f40d | 2015-02-23 14:26:59 +0100 | [diff] [blame] | 389 | test_tbf_final_ack(TEST_MODE_STANDARD); |
| 390 | test_tbf_final_ack(TEST_MODE_REVERSE_FREE); |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 391 | test_tbf_delayed_release(); |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 392 | test_tbf_exhaustion(); |
Jacob Erlbeck | 67c3850 | 2015-05-11 10:32:40 +0200 | [diff] [blame] | 393 | |
| 394 | if (getenv("TALLOC_REPORT_FULL")) |
| 395 | talloc_report_full(tall_pcu_ctx, stderr); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 396 | return EXIT_SUCCESS; |
| 397 | } |
| 398 | |
| 399 | /* |
| 400 | * stubs that should not be reached |
| 401 | */ |
| 402 | extern "C" { |
| 403 | void l1if_pdch_req() { abort(); } |
| 404 | void l1if_connect_pdch() { abort(); } |
| 405 | void l1if_close_pdch() { abort(); } |
| 406 | void l1if_open_pdch() { abort(); } |
| 407 | } |