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; |
| 54 | the_bts.bts_data()->alloc_algorithm = alloc_algorithm_a; |
| 55 | the_bts.bts_data()->trx[0].pdch[2].enable(); |
| 56 | the_bts.bts_data()->trx[0].pdch[3].enable(); |
| 57 | |
| 58 | /* |
| 59 | * Make a uplink and downlink allocation |
| 60 | */ |
Daniel Willmann | 48aa0b0 | 2014-07-16 18:54:10 +0200 | [diff] [blame] | 61 | gprs_rlcmac_tbf *dl_tbf = tbf_alloc_dl_tbf(the_bts.bts_data(), |
| 62 | NULL, 0, |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 63 | 0, 0, 0); |
| 64 | dl_tbf->update_tlli(0x2342); |
| 65 | dl_tbf->tlli_mark_valid(); |
| 66 | dl_tbf->ta = 4; |
| 67 | the_bts.timing_advance()->remember(0x2342, dl_tbf->ta); |
| 68 | |
Daniel Willmann | 48aa0b0 | 2014-07-16 18:54:10 +0200 | [diff] [blame] | 69 | 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] | 70 | dl_tbf, 0, |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 71 | 0, 0, 0); |
| 72 | ul_tbf->update_tlli(0x2342); |
| 73 | ul_tbf->tlli_mark_valid(); |
| 74 | |
| 75 | |
Daniel Willmann | b59d61b | 2014-07-02 17:58:14 +0200 | [diff] [blame] | 76 | OSMO_ASSERT(the_bts.dl_tbf_by_tlli(0x2342) == dl_tbf); |
| 77 | OSMO_ASSERT(the_bts.ul_tbf_by_tlli(0x2342) == ul_tbf); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 78 | |
| 79 | |
| 80 | /* |
| 81 | * Now check.. that DL changes and that the timing advance |
| 82 | * has changed. |
| 83 | */ |
| 84 | dl_tbf->update_tlli(0x4232); |
Daniel Willmann | b59d61b | 2014-07-02 17:58:14 +0200 | [diff] [blame] | 85 | OSMO_ASSERT(!the_bts.dl_tbf_by_tlli(0x2342)); |
| 86 | OSMO_ASSERT(!the_bts.ul_tbf_by_tlli(0x2342)); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 87 | |
| 88 | |
Daniel Willmann | b59d61b | 2014-07-02 17:58:14 +0200 | [diff] [blame] | 89 | OSMO_ASSERT(the_bts.dl_tbf_by_tlli(0x4232) == dl_tbf); |
| 90 | OSMO_ASSERT(the_bts.ul_tbf_by_tlli(0x4232) == ul_tbf); |
Holger Hans Peter Freyther | bc1626e | 2013-10-30 19:50:49 +0100 | [diff] [blame] | 91 | |
| 92 | OSMO_ASSERT(the_bts.timing_advance()->recall(0x4232) == 4); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 93 | } |
| 94 | |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 95 | static uint8_t llc_data[200]; |
| 96 | |
| 97 | int pcu_sock_send(struct msgb *msg) |
| 98 | { |
| 99 | return 0; |
| 100 | } |
| 101 | |
Jacob Erlbeck | a3e4509 | 2015-03-25 09:11:24 +0100 | [diff] [blame] | 102 | static void setup_bts(BTS *the_bts, uint8_t ts_no) |
| 103 | { |
| 104 | gprs_rlcmac_bts *bts; |
| 105 | gprs_rlcmac_trx *trx; |
| 106 | |
| 107 | bts = the_bts->bts_data(); |
| 108 | bts->alloc_algorithm = alloc_algorithm_a; |
| 109 | trx = &bts->trx[0]; |
| 110 | |
| 111 | trx->pdch[ts_no].enable(); |
| 112 | } |
| 113 | |
| 114 | static gprs_rlcmac_dl_tbf *create_dl_tbf(BTS *the_bts, uint8_t ms_class, |
| 115 | uint8_t *trx_no_) |
| 116 | { |
| 117 | gprs_rlcmac_bts *bts; |
| 118 | int tfi; |
| 119 | uint8_t trx_no; |
| 120 | |
| 121 | gprs_rlcmac_dl_tbf *dl_tbf; |
| 122 | |
| 123 | bts = the_bts->bts_data(); |
| 124 | |
| 125 | tfi = the_bts->tfi_find_free(GPRS_RLCMAC_DL_TBF, &trx_no, -1); |
| 126 | OSMO_ASSERT(tfi >= 0); |
| 127 | dl_tbf = tbf_alloc_dl_tbf(bts, NULL, tfi, trx_no, ms_class, 1); |
| 128 | check_tbf(dl_tbf); |
| 129 | |
| 130 | /* "Establish" the DL TBF */ |
| 131 | dl_tbf->dl_ass_state = GPRS_RLCMAC_DL_ASS_SEND_ASS; |
| 132 | dl_tbf->set_state(GPRS_RLCMAC_FLOW); |
| 133 | dl_tbf->m_wait_confirm = 0; |
| 134 | dl_tbf->set_new_tbf(dl_tbf); |
| 135 | check_tbf(dl_tbf); |
| 136 | |
| 137 | *trx_no_ = trx_no; |
| 138 | |
| 139 | return dl_tbf; |
| 140 | } |
| 141 | |
Jacob Erlbeck | 2493c66 | 2015-03-25 10:05:34 +0100 | [diff] [blame] | 142 | static void send_rlc_block(struct gprs_rlcmac_bts *bts, |
| 143 | uint8_t trx_no, uint8_t ts_no, uint16_t arfcn, |
| 144 | uint32_t *fn, uint8_t *block_nr) |
| 145 | { |
| 146 | gprs_rlcmac_rcv_rts_block(bts, trx_no, ts_no, 0, *fn, *block_nr); |
| 147 | *fn += 4; |
| 148 | if ((*fn % 13) == 12) |
| 149 | *fn += 1; |
| 150 | *block_nr += 1; |
| 151 | } |
| 152 | |
Jacob Erlbeck | 5e9f40d | 2015-02-23 14:26:59 +0100 | [diff] [blame] | 153 | enum test_tbf_final_ack_mode { |
| 154 | TEST_MODE_STANDARD, |
| 155 | TEST_MODE_REVERSE_FREE |
| 156 | }; |
| 157 | |
| 158 | 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] | 159 | { |
| 160 | BTS the_bts; |
| 161 | gprs_rlcmac_bts *bts; |
Jacob Erlbeck | a3e4509 | 2015-03-25 09:11:24 +0100 | [diff] [blame] | 162 | uint8_t ts_no = 4; |
| 163 | unsigned i; |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 164 | uint8_t ms_class = 45; |
| 165 | uint32_t fn; |
Jacob Erlbeck | 2493c66 | 2015-03-25 10:05:34 +0100 | [diff] [blame] | 166 | uint8_t block_nr; |
Jacob Erlbeck | a3e4509 | 2015-03-25 09:11:24 +0100 | [diff] [blame] | 167 | uint8_t trx_no; |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 168 | |
| 169 | uint8_t rbb[64/8]; |
| 170 | |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 171 | gprs_rlcmac_dl_tbf *dl_tbf; |
| 172 | gprs_rlcmac_tbf *new_tbf; |
| 173 | |
| 174 | bts = the_bts.bts_data(); |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 175 | |
Jacob Erlbeck | a3e4509 | 2015-03-25 09:11:24 +0100 | [diff] [blame] | 176 | setup_bts(&the_bts, ts_no); |
| 177 | dl_tbf = create_dl_tbf(&the_bts, ms_class, &trx_no); |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 178 | |
| 179 | for (i = 0; i < sizeof(llc_data); i++) |
| 180 | llc_data[i] = i%256; |
| 181 | |
Jacob Erlbeck | 2493c66 | 2015-03-25 10:05:34 +0100 | [diff] [blame] | 182 | /* Schedule two LLC frames */ |
Daniel Willmann | 0f58af6 | 2014-09-19 11:57:21 +0200 | [diff] [blame] | 183 | dl_tbf->append_data(ms_class, 1000, llc_data, sizeof(llc_data)); |
| 184 | dl_tbf->append_data(ms_class, 1000, llc_data, sizeof(llc_data)); |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 185 | |
| 186 | |
Jacob Erlbeck | 2493c66 | 2015-03-25 10:05:34 +0100 | [diff] [blame] | 187 | /* Send only a few RLC/MAC blocks */ |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 188 | fn = 0; |
Jacob Erlbeck | 2493c66 | 2015-03-25 10:05:34 +0100 | [diff] [blame] | 189 | block_nr = 0; |
| 190 | while (block_nr < 3) { |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 191 | /* Request to send one block */ |
Jacob Erlbeck | 2493c66 | 2015-03-25 10:05:34 +0100 | [diff] [blame] | 192 | send_rlc_block(bts, trx_no, ts_no, 0, &fn, &block_nr); |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 193 | } |
Jacob Erlbeck | 2493c66 | 2015-03-25 10:05:34 +0100 | [diff] [blame] | 194 | OSMO_ASSERT(dl_tbf->have_data()); |
| 195 | OSMO_ASSERT(dl_tbf->state_is(GPRS_RLCMAC_FLOW)); |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 196 | |
| 197 | /* Queue a final ACK */ |
| 198 | memset(rbb, 0, sizeof(rbb)); |
| 199 | /* Receive a final ACK */ |
| 200 | dl_tbf->rcvd_dl_ack(1, 1, rbb); |
| 201 | |
| 202 | /* Clean up and ensure tbfs are in the correct state */ |
| 203 | OSMO_ASSERT(dl_tbf->state_is(GPRS_RLCMAC_WAIT_RELEASE)); |
| 204 | new_tbf = dl_tbf->new_tbf(); |
Jacob Erlbeck | 08fe76a | 2015-02-23 15:10:20 +0100 | [diff] [blame] | 205 | check_tbf(new_tbf); |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 206 | OSMO_ASSERT(new_tbf != dl_tbf); |
| 207 | OSMO_ASSERT(new_tbf->tfi() == 1); |
Jacob Erlbeck | 08fe76a | 2015-02-23 15:10:20 +0100 | [diff] [blame] | 208 | check_tbf(dl_tbf); |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 209 | dl_tbf->dl_ass_state = GPRS_RLCMAC_DL_ASS_NONE; |
Jacob Erlbeck | 5e9f40d | 2015-02-23 14:26:59 +0100 | [diff] [blame] | 210 | if (test_mode == TEST_MODE_REVERSE_FREE) { |
| 211 | tbf_free(new_tbf); |
Jacob Erlbeck | 08fe76a | 2015-02-23 15:10:20 +0100 | [diff] [blame] | 212 | OSMO_ASSERT(dl_tbf->m_new_tbf != new_tbf); |
| 213 | check_tbf(dl_tbf); |
Jacob Erlbeck | 5e9f40d | 2015-02-23 14:26:59 +0100 | [diff] [blame] | 214 | tbf_free(dl_tbf); |
| 215 | } else { |
| 216 | tbf_free(dl_tbf); |
| 217 | OSMO_ASSERT(new_tbf->m_new_tbf != dl_tbf); |
Jacob Erlbeck | 08fe76a | 2015-02-23 15:10:20 +0100 | [diff] [blame] | 218 | check_tbf(new_tbf); |
Jacob Erlbeck | 5e9f40d | 2015-02-23 14:26:59 +0100 | [diff] [blame] | 219 | tbf_free(new_tbf); |
| 220 | } |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 221 | } |
| 222 | |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 223 | static void test_tbf_delayed_release() |
| 224 | { |
| 225 | BTS the_bts; |
| 226 | gprs_rlcmac_bts *bts; |
| 227 | uint8_t ts_no = 4; |
| 228 | unsigned i; |
| 229 | uint8_t ms_class = 45; |
| 230 | uint32_t fn = 0; |
| 231 | uint8_t block_nr = 0; |
| 232 | uint8_t trx_no; |
| 233 | |
| 234 | uint8_t rbb[64/8]; |
| 235 | |
| 236 | gprs_rlcmac_dl_tbf *dl_tbf; |
| 237 | |
| 238 | printf("=== start %s ===\n", __func__); |
| 239 | |
| 240 | bts = the_bts.bts_data(); |
| 241 | |
| 242 | setup_bts(&the_bts, ts_no); |
| 243 | bts->dl_tbf_idle_msec = 200; |
| 244 | |
| 245 | dl_tbf = create_dl_tbf(&the_bts, ms_class, &trx_no); |
| 246 | |
| 247 | for (i = 0; i < sizeof(llc_data); i++) |
| 248 | llc_data[i] = i%256; |
| 249 | |
| 250 | OSMO_ASSERT(dl_tbf->state_is(GPRS_RLCMAC_FLOW)); |
| 251 | |
| 252 | /* Schedule two LLC frames */ |
| 253 | dl_tbf->append_data(ms_class, 1000, llc_data, sizeof(llc_data)); |
| 254 | dl_tbf->append_data(ms_class, 1000, llc_data, sizeof(llc_data)); |
| 255 | |
| 256 | OSMO_ASSERT(dl_tbf->state_is(GPRS_RLCMAC_FLOW)); |
| 257 | |
| 258 | /* Drain the queue */ |
| 259 | while (dl_tbf->have_data()) |
| 260 | /* Request to send one RLC/MAC block */ |
| 261 | send_rlc_block(bts, trx_no, ts_no, 0, &fn, &block_nr); |
| 262 | |
| 263 | OSMO_ASSERT(dl_tbf->state_is(GPRS_RLCMAC_FLOW)); |
| 264 | |
| 265 | /* ACK all blocks */ |
| 266 | memset(rbb, 0xff, sizeof(rbb)); |
| 267 | /* Receive an ACK */ |
| 268 | dl_tbf->rcvd_dl_ack(0, dl_tbf->m_window.v_s(), rbb); |
| 269 | OSMO_ASSERT(dl_tbf->m_window.window_empty()); |
| 270 | |
| 271 | /* Force sending of a single block containing an LLC dummy command */ |
| 272 | send_rlc_block(bts, trx_no, ts_no, 0, &fn, &block_nr); |
| 273 | |
| 274 | /* Receive an ACK */ |
| 275 | dl_tbf->rcvd_dl_ack(0, dl_tbf->m_window.v_s(), rbb); |
| 276 | OSMO_ASSERT(dl_tbf->m_window.window_empty()); |
| 277 | |
| 278 | /* Timeout (make sure fn % 52 remains valid) */ |
| 279 | fn += 52 * ((msecs_to_frames(bts->dl_tbf_idle_msec + 100) + 51)/ 52); |
| 280 | send_rlc_block(bts, trx_no, ts_no, 0, &fn, &block_nr); |
| 281 | |
| 282 | OSMO_ASSERT(dl_tbf->state_is(GPRS_RLCMAC_FINISHED)); |
| 283 | |
| 284 | /* Receive a final ACK */ |
| 285 | dl_tbf->rcvd_dl_ack(1, dl_tbf->m_window.v_s(), rbb); |
| 286 | |
| 287 | /* Clean up and ensure tbfs are in the correct state */ |
| 288 | OSMO_ASSERT(dl_tbf->state_is(GPRS_RLCMAC_WAIT_RELEASE)); |
| 289 | OSMO_ASSERT(dl_tbf->new_tbf() == dl_tbf); |
| 290 | dl_tbf->dl_ass_state = GPRS_RLCMAC_DL_ASS_NONE; |
| 291 | check_tbf(dl_tbf); |
| 292 | tbf_free(dl_tbf); |
| 293 | printf("=== end %s ===\n", __func__); |
| 294 | } |
| 295 | |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 296 | static void test_tbf_exhaustion() |
| 297 | { |
| 298 | BTS the_bts; |
| 299 | gprs_rlcmac_bts *bts; |
| 300 | unsigned i; |
| 301 | uint8_t ts_no = 4; |
| 302 | uint8_t ms_class = 45; |
| 303 | int rc = 0; |
| 304 | |
| 305 | uint8_t buf[256] = {0}; |
| 306 | |
| 307 | printf("=== start %s ===\n", __func__); |
| 308 | |
| 309 | bts = the_bts.bts_data(); |
| 310 | setup_bts(&the_bts, ts_no); |
| 311 | gprs_bssgp_create_and_connect(bts, 33001, 0, 33001, |
| 312 | 1234, 1234, 1234, 1, 1, 0, 0, 0); |
| 313 | |
| 314 | for (i = 0; i < 1024; i++) { |
| 315 | uint32_t tlli = 0xc0000000 + i; |
| 316 | char imsi[16] = {0}; |
| 317 | unsigned delay_csec = 1000; |
| 318 | |
| 319 | snprintf(imsi, sizeof(imsi)-1, "001001%9d", i); |
| 320 | |
| 321 | rc = gprs_rlcmac_dl_tbf::handle(bts, tlli, imsi, ms_class, |
| 322 | delay_csec, buf, sizeof(buf)); |
| 323 | |
| 324 | if (rc < 0) |
| 325 | break; |
| 326 | } |
| 327 | |
| 328 | OSMO_ASSERT(rc == -EBUSY); |
| 329 | printf("=== end %s ===\n", __func__); |
| 330 | |
| 331 | gprs_bssgp_destroy(); |
| 332 | } |
| 333 | |
Daniel Willmann | 341689d | 2014-06-11 18:33:14 +0200 | [diff] [blame] | 334 | static const struct log_info_cat default_categories[] = { |
| 335 | {"DCSN1", "\033[1;31m", "Concrete Syntax Notation One (CSN1)", LOGL_INFO, 0}, |
| 336 | {"DL1IF", "\033[1;32m", "GPRS PCU L1 interface (L1IF)", LOGL_DEBUG, 1}, |
| 337 | {"DRLCMAC", "\033[0;33m", "GPRS RLC/MAC layer (RLCMAC)", LOGL_DEBUG, 1}, |
| 338 | {"DRLCMACDATA", "\033[0;33m", "GPRS RLC/MAC layer Data (RLCMAC)", LOGL_DEBUG, 1}, |
| 339 | {"DRLCMACDL", "\033[1;33m", "GPRS RLC/MAC layer Downlink (RLCMAC)", LOGL_DEBUG, 1}, |
| 340 | {"DRLCMACUL", "\033[1;36m", "GPRS RLC/MAC layer Uplink (RLCMAC)", LOGL_DEBUG, 1}, |
| 341 | {"DRLCMACSCHED", "\033[0;36m", "GPRS RLC/MAC layer Scheduling (RLCMAC)", LOGL_DEBUG, 1}, |
| 342 | {"DRLCMACMEAS", "\033[1;31m", "GPRS RLC/MAC layer Measurements (RLCMAC)", LOGL_INFO, 1}, |
| 343 | {"DBSSGP","\033[1;34m", "GPRS BSS Gateway Protocol (BSSGP)", LOGL_INFO , 1}, |
| 344 | {"DPCU", "\033[1;35m", "GPRS Packet Control Unit (PCU)", LOGL_NOTICE, 1}, |
| 345 | }; |
| 346 | |
| 347 | static int filter_fn(const struct log_context *ctx, |
| 348 | struct log_target *tar) |
| 349 | { |
| 350 | return 1; |
| 351 | } |
| 352 | |
| 353 | const struct log_info debug_log_info = { |
| 354 | filter_fn, |
| 355 | (struct log_info_cat*)default_categories, |
| 356 | ARRAY_SIZE(default_categories), |
| 357 | }; |
| 358 | |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 359 | int main(int argc, char **argv) |
| 360 | { |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 361 | struct vty_app_info pcu_vty_info = {0}; |
| 362 | |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 363 | tall_pcu_ctx = talloc_named_const(NULL, 1, "moiji-mobile TbfTest context"); |
| 364 | if (!tall_pcu_ctx) |
| 365 | abort(); |
| 366 | |
| 367 | msgb_set_talloc_ctx(tall_pcu_ctx); |
Daniel Willmann | 341689d | 2014-06-11 18:33:14 +0200 | [diff] [blame] | 368 | osmo_init_logging(&debug_log_info); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 369 | log_set_use_color(osmo_stderr_target, 0); |
| 370 | log_set_print_filename(osmo_stderr_target, 0); |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 371 | bssgp_set_log_ss(DBSSGP); |
| 372 | |
| 373 | vty_init(&pcu_vty_info); |
| 374 | pcu_vty_init(&debug_log_info); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 375 | |
| 376 | test_tbf_tlli_update(); |
Jacob Erlbeck | 5e9f40d | 2015-02-23 14:26:59 +0100 | [diff] [blame] | 377 | test_tbf_final_ack(TEST_MODE_STANDARD); |
| 378 | test_tbf_final_ack(TEST_MODE_REVERSE_FREE); |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 379 | test_tbf_delayed_release(); |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 380 | test_tbf_exhaustion(); |
Jacob Erlbeck | 67c3850 | 2015-05-11 10:32:40 +0200 | [diff] [blame] | 381 | |
| 382 | if (getenv("TALLOC_REPORT_FULL")) |
| 383 | talloc_report_full(tall_pcu_ctx, stderr); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 384 | return EXIT_SUCCESS; |
| 385 | } |
| 386 | |
| 387 | /* |
| 388 | * stubs that should not be reached |
| 389 | */ |
| 390 | extern "C" { |
| 391 | void l1if_pdch_req() { abort(); } |
| 392 | void l1if_connect_pdch() { abort(); } |
| 393 | void l1if_close_pdch() { abort(); } |
| 394 | void l1if_open_pdch() { abort(); } |
| 395 | } |