blob: 6d71a8c6385529b82e93af45819e6b7e3f361c2d [file] [log] [blame]
Alexander Couzens1c8785d2020-12-17 06:58:53 +01001/* test routines for NS connection handling
2 * (C) 2020 sysmocom - s.f.m.c. GmbH
3 * Author: Alexander Couzens <lynxis@fe80.eu>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#undef _GNU_SOURCE
9#define _GNU_SOURCE
10
11#include <stdio.h>
12#include <stdlib.h>
13#include <unistd.h>
14#include <stdint.h>
15#include <string.h>
16#include <getopt.h>
17#include <dlfcn.h>
18#include <sys/types.h>
19#include <sys/socket.h>
20
21#include <osmocom/core/fsm.h>
22#include <osmocom/core/msgb.h>
Alexander Couzens47afc422021-01-17 20:12:46 +010023#include <osmocom/core/utils.h>
Alexander Couzens1c8785d2020-12-17 06:58:53 +010024#include <osmocom/core/application.h>
25#include <osmocom/core/utils.h>
26#include <osmocom/core/logging.h>
27#include <osmocom/core/socket.h>
28#include <osmocom/core/talloc.h>
29#include <osmocom/core/write_queue.h>
30#include <osmocom/gprs/gprs_msgb.h>
31#include <osmocom/gprs/gprs_ns2.h>
32#include <osmocom/gprs/gprs_bssgp.h>
33
34#include "../../src/gb/gprs_ns2_internal.h"
35
36int bssgp_prim_cb(struct osmo_prim_hdr *oph, void *ctx)
37{
38 return -1;
39}
40
41static struct log_info info = {};
Alexander Couzens8f215c92021-01-25 15:27:56 +010042static struct osmo_wqueue *unitdata = NULL;
Alexander Couzens4f1128f2021-01-20 17:42:48 +010043static struct osmo_gprs_ns2_prim last_nse_recovery = {};
Alexander Couzens1c8785d2020-12-17 06:58:53 +010044
45static int ns_prim_cb(struct osmo_prim_hdr *oph, void *ctx)
46{
Alexander Couzens4f1128f2021-01-20 17:42:48 +010047 struct osmo_gprs_ns2_prim *nsp;
Alexander Couzens8f215c92021-01-25 15:27:56 +010048 OSMO_ASSERT(oph->sap == SAP_NS);
Alexander Couzens4f1128f2021-01-20 17:42:48 +010049 nsp = container_of(oph, struct osmo_gprs_ns2_prim, oph);
Alexander Couzens8f215c92021-01-25 15:27:56 +010050 if (oph->msg) {
Alexander Couzens138b96f2021-01-25 16:23:29 +010051 if (oph->primitive == GPRS_NS2_PRIM_UNIT_DATA) {
Alexander Couzens8f215c92021-01-25 15:27:56 +010052 osmo_wqueue_enqueue(unitdata, oph->msg);
53 } else {
54 msgb_free(oph->msg);
55 }
56 }
Alexander Couzens4f1128f2021-01-20 17:42:48 +010057 if (oph->primitive == GPRS_NS2_PRIM_STATUS && nsp->u.status.cause == GPRS_NS2_AFF_CAUSE_RECOVERY) {
58 last_nse_recovery = *nsp;
59 }
Alexander Couzens1c8785d2020-12-17 06:58:53 +010060 return 0;
61}
62
Alexander Couzens47afc422021-01-17 20:12:46 +010063static struct msgb *get_pdu(struct gprs_ns2_vc_bind *bind, enum ns_pdu_type pdu_type)
64{
65 struct gprs_ns_hdr *nsh;
66 struct osmo_wqueue *queue = bind->priv;
67
68 while (!llist_empty(&queue->msg_queue)) {
69 struct msgb *msg = msgb_dequeue(&queue->msg_queue);
70 nsh = (struct gprs_ns_hdr *) msg->l2h;
71 if (nsh->pdu_type == pdu_type)
72 return msg;
73 msgb_free(msg);
74 }
75
76 return NULL;
77}
78
79static bool find_pdu(struct gprs_ns2_vc_bind *bind, enum ns_pdu_type pdu_type)
80{
81 struct msgb *msg;
82 msg = get_pdu(bind, pdu_type);
83 if (msg) {
84 msgb_free(msg);
85 return true;
86 }
87
88 return false;
89}
90
Alexander Couzensaf5bfeb2021-01-17 20:12:37 +010091static void clear_pdus(struct gprs_ns2_vc_bind *bind)
Alexander Couzens1c8785d2020-12-17 06:58:53 +010092{
Alexander Couzensaf5bfeb2021-01-17 20:12:37 +010093 struct osmo_wqueue *queue = bind->priv;
94 osmo_wqueue_clear(queue);
Alexander Couzens1c8785d2020-12-17 06:58:53 +010095}
96
97struct gprs_ns2_vc_driver vc_driver_dummy = {
98 .name = "GB UDP dummy",
Alexander Couzensaf5bfeb2021-01-17 20:12:37 +010099 .free_bind = clear_pdus,
Alexander Couzens1c8785d2020-12-17 06:58:53 +0100100};
101
102static int vc_sendmsg(struct gprs_ns2_vc *nsvc, struct msgb *msg)
103{
104 struct gprs_ns2_vc_bind *bind = nsvc->bind;
105 struct osmo_wqueue *queue = bind->priv;
106
107 osmo_wqueue_enqueue(queue, msg);
108 return 0;
109}
110
111static struct gprs_ns2_vc_bind *dummy_bind(struct gprs_ns2_inst *nsi, const char *name)
112{
Harald Weltec3aa8f92021-01-31 11:41:34 +0100113 struct gprs_ns2_vc_bind *bind = NULL;
114 OSMO_ASSERT(ns2_bind_alloc(nsi, name, &bind) == 0);
Alexander Couzens1c8785d2020-12-17 06:58:53 +0100115 OSMO_ASSERT(bind);
116
Alexander Couzens1c8785d2020-12-17 06:58:53 +0100117 bind->driver = &vc_driver_dummy;
118 bind->ll = GPRS_NS2_LL_UDP;
119 bind->transfer_capability = 42;
Alexander Couzens1c8785d2020-12-17 06:58:53 +0100120 bind->send_vc = vc_sendmsg;
121 bind->priv = talloc_zero(bind, struct osmo_wqueue);
Alexander Couzens4f1128f2021-01-20 17:42:48 +0100122 bind->mtu = 123;
Alexander Couzens1c8785d2020-12-17 06:58:53 +0100123 struct osmo_wqueue *queue = bind->priv;
124
Alexander Couzens1c8785d2020-12-17 06:58:53 +0100125 osmo_wqueue_init(queue, 100);
126
127 return bind;
128}
129
Alexander Couzens8f215c92021-01-25 15:27:56 +0100130static void free_loopback(struct gprs_ns2_vc_bind *bind) {}
131
132struct gprs_ns2_vc_driver vc_driver_loopback = {
133 .name = "loopback dummy",
134 .free_bind = free_loopback,
135};
136
137/* loopback the msg */
138static int loopback_sendmsg(struct gprs_ns2_vc *nsvc, struct msgb *msg)
139{
140 struct gprs_ns2_vc *target = nsvc->priv;
141 return ns2_recv_vc(target, msg);
142}
143
144/* create a loopback nsvc object which can be used with ns2_tx_* functions. it's not fully registered etc. */
145static struct gprs_ns2_vc *loopback_nsvc(struct gprs_ns2_vc_bind *bind, struct gprs_ns2_vc *target)
146{
147 struct gprs_ns2_vc *nsvc = talloc_zero(bind, struct gprs_ns2_vc);
148 memcpy(nsvc, target, sizeof(struct gprs_ns2_vc));
149 nsvc->bind = bind;
150 nsvc->priv = target;
151 return nsvc;
152}
153
154/* a loop back bind to use the tx_ functions from gprs_ns2_message.c */
155static struct gprs_ns2_vc_bind *loopback_bind(struct gprs_ns2_inst *nsi, const char *name)
156{
Harald Weltec3aa8f92021-01-31 11:41:34 +0100157 struct gprs_ns2_vc_bind *bind = NULL;
158 OSMO_ASSERT(ns2_bind_alloc(nsi, name, &bind) == 0)
Alexander Couzens8f215c92021-01-25 15:27:56 +0100159 OSMO_ASSERT(bind);
Alexander Couzens8f215c92021-01-25 15:27:56 +0100160 bind->driver = &vc_driver_loopback;
161 bind->ll = GPRS_NS2_LL_UDP;
162 bind->transfer_capability = 99;
Alexander Couzens8f215c92021-01-25 15:27:56 +0100163 bind->send_vc = loopback_sendmsg;
Alexander Couzens4f1128f2021-01-20 17:42:48 +0100164 bind->mtu = 123;
Alexander Couzens8f215c92021-01-25 15:27:56 +0100165 return bind;
166}
167
Alexander Couzens1c8785d2020-12-17 06:58:53 +0100168void test_nse_transfer_cap(void *ctx)
169{
170 struct gprs_ns2_inst *nsi;
171 struct gprs_ns2_vc_bind *bind[2];
172 struct gprs_ns2_nse *nse;
173 struct gprs_ns2_vc *nsvc[3];
174
175 /* create a UDP dummy bind[0] with transfer cap 42.
176 * create nse (nsei 1001)
177 * create 2x nsvc with the same bind.
178 * nsvc[0] or nsvc[1] is alive (or both) cap == 42
179 *
180 * create a second bind with transfer cap == 23
181 * create 3rd nsvc with bind[1]
182 * transfer cap should be 42 + 23
183 */
184
185 printf("--- Testing NSE transfer cap\n");
186
187 printf("---- Create NSE + Binds\n");
188 nsi = gprs_ns2_instantiate(ctx, ns_prim_cb, NULL);
189 bind[0] = dummy_bind(nsi, "transfercap1");
190 bind[1] = dummy_bind(nsi, "transfercap2");
191 bind[1]->transfer_capability = 23;
Alexander Couzens138b96f2021-01-25 16:23:29 +0100192 nse = gprs_ns2_create_nse(nsi, 1001, GPRS_NS2_LL_UDP, GPRS_NS2_DIALECT_STATIC_ALIVE);
Alexander Couzens1c8785d2020-12-17 06:58:53 +0100193 OSMO_ASSERT(nse);
194
195 printf("---- Test with NSVC[0]\n");
Alexander Couzens138b96f2021-01-25 16:23:29 +0100196 nsvc[0] = ns2_vc_alloc(bind[0], nse, false, GPRS_NS2_VC_MODE_ALIVE, NULL);
Alexander Couzens1c8785d2020-12-17 06:58:53 +0100197 OSMO_ASSERT(nsvc[0]);
198 OSMO_ASSERT(ns2_count_transfer_cap(nse, 0) == 0);
199 nsvc[0]->fi->state = 3; /* HACK: 3 = GPRS_NS2_ST_UNBLOCKED */
200 ns2_nse_notify_unblocked(nsvc[0], true);
201 OSMO_ASSERT(ns2_count_transfer_cap(nse, 0) == 42);
202
203 printf("---- Test with NSVC[1]\n");
Alexander Couzens138b96f2021-01-25 16:23:29 +0100204 nsvc[1] = ns2_vc_alloc(bind[0], nse, false, GPRS_NS2_VC_MODE_ALIVE, NULL);
Alexander Couzens1c8785d2020-12-17 06:58:53 +0100205 OSMO_ASSERT(nsvc[1]);
206 OSMO_ASSERT(ns2_count_transfer_cap(nse, 0) == 42);
207 nsvc[1]->fi->state = 3; /* HACK: 3 = GPRS_NS2_ST_UNBLOCKED */
208 ns2_nse_notify_unblocked(nsvc[1], true);
209 OSMO_ASSERT(ns2_count_transfer_cap(nse, 0) == 42);
210
211 printf("---- Test with NSVC[2]\n");
Alexander Couzens138b96f2021-01-25 16:23:29 +0100212 nsvc[2] = ns2_vc_alloc(bind[1], nse, false, GPRS_NS2_VC_MODE_ALIVE, NULL);
Alexander Couzens1c8785d2020-12-17 06:58:53 +0100213 OSMO_ASSERT(nsvc[2]);
214 OSMO_ASSERT(ns2_count_transfer_cap(nse, 0) == 42);
215 nsvc[2]->fi->state = 3; /* HACK: 3 = GPRS_NS2_ST_UNBLOCKED */
216 ns2_nse_notify_unblocked(nsvc[2], true);
217 OSMO_ASSERT(ns2_count_transfer_cap(nse, 0) == 42 + 23);
218
219 printf("---- Test with NSVC[1] removed\n");
220 /* reset nsvc[1] to be unconfigured - shouldn't change anything */
221 nsvc[1]->fi->state = 0; /* HACK: 0 = GPRS_NS2_ST_UNCONFIGURED */
222 ns2_nse_notify_unblocked(nsvc[1], false);
223 OSMO_ASSERT(ns2_count_transfer_cap(nse, 0) == 42 + 23);
224
Alexander Couzensaca31b82021-01-17 20:15:20 +0100225 gprs_ns2_free(nsi);
Alexander Couzens1c8785d2020-12-17 06:58:53 +0100226 printf("--- Finish NSE transfer cap\n");
227
228}
229
Alexander Couzens47afc422021-01-17 20:12:46 +0100230/* setup NSE with 2x NSVCs.
231 * block 1x NSVC
232 * unblock 1x NSVC*/
233void test_block_unblock_nsvc(void *ctx)
234{
235 struct gprs_ns2_inst *nsi;
236 struct gprs_ns2_vc_bind *bind[2];
237 struct gprs_ns2_nse *nse;
238 struct gprs_ns2_vc *nsvc[2];
239 struct gprs_ns_hdr *nsh;
240 struct msgb *msg;
241 char idbuf[32];
Harald Welte2846ee22021-01-21 10:22:09 +0100242 int i;
Alexander Couzens47afc422021-01-17 20:12:46 +0100243
244 printf("--- Testing NSE block unblock nsvc\n");
245 printf("---- Create NSE + Binds\n");
246 nsi = gprs_ns2_instantiate(ctx, ns_prim_cb, NULL);
247 bind[0] = dummy_bind(nsi, "bblock1");
248 bind[1] = dummy_bind(nsi, "bblock2");
Alexander Couzens138b96f2021-01-25 16:23:29 +0100249 nse = gprs_ns2_create_nse(nsi, 1001, GPRS_NS2_LL_UDP, GPRS_NS2_DIALECT_STATIC_RESETBLOCK);
Alexander Couzens47afc422021-01-17 20:12:46 +0100250 OSMO_ASSERT(nse);
251
Harald Welte2846ee22021-01-21 10:22:09 +0100252 for (i=0; i<2; i++) {
Alexander Couzens47afc422021-01-17 20:12:46 +0100253 printf("---- Create NSVC[i]\n");
254 snprintf(idbuf, sizeof(idbuf), "NSE%05u-dummy-%i", nse->nsei, i);
Alexander Couzens138b96f2021-01-25 16:23:29 +0100255 nsvc[i] = ns2_vc_alloc(bind[i], nse, false, GPRS_NS2_VC_MODE_BLOCKRESET, idbuf);
Alexander Couzens47afc422021-01-17 20:12:46 +0100256 OSMO_ASSERT(nsvc[i]);
257 nsvc[i]->fi->state = 3; /* HACK: 3 = GPRS_NS2_ST_UNBLOCKED */
258 /* ensure the fi->state works correct */
Alexander Couzens8dfc24c2021-01-25 16:09:23 +0100259 OSMO_ASSERT(ns2_vc_is_unblocked(nsvc[i]));
Alexander Couzens47afc422021-01-17 20:12:46 +0100260 ns2_nse_notify_unblocked(nsvc[i], true);
261 }
262
263 /* both nsvcs are unblocked and alive. Let's block it. */
264 OSMO_ASSERT(!find_pdu(bind[0], NS_PDUT_BLOCK));
265 clear_pdus(bind[0]);
266 ns2_vc_block(nsvc[0]);
267 OSMO_ASSERT(find_pdu(bind[0], NS_PDUT_BLOCK));
268 /* state == BLOCKED */
269 clear_pdus(bind[0]);
270
271 /* now unblocking it */
272 ns2_vc_unblock(nsvc[0]);
273 OSMO_ASSERT(find_pdu(bind[0], NS_PDUT_UNBLOCK));
274 clear_pdus(bind[0]);
275
276 msg = msgb_alloc_headroom(NS_ALLOC_SIZE, NS_ALLOC_HEADROOM, "test_unblock");
277 msg->l2h = msgb_put(msg, sizeof(*nsh));
278 nsh = (struct gprs_ns_hdr *) msg->l2h;
279 nsh->pdu_type = NS_PDUT_UNBLOCK_ACK;
280 ns2_recv_vc(nsvc[0], msg);
281
Alexander Couzens8dfc24c2021-01-25 16:09:23 +0100282 OSMO_ASSERT(ns2_vc_is_unblocked(nsvc[0]));
Alexander Couzens47afc422021-01-17 20:12:46 +0100283 gprs_ns2_free(nsi);
284 printf("--- Finish NSE block unblock nsvc\n");
285}
286
Alexander Couzens8f215c92021-01-25 15:27:56 +0100287static struct msgb *generate_unitdata(const char *msgname)
288{
289 struct gprs_ns_hdr *nsh;
290 struct msgb *msg = msgb_alloc_headroom(NS_ALLOC_SIZE, NS_ALLOC_HEADROOM, msgname);
291 OSMO_ASSERT(msg);
292
293 msg->l2h = msgb_put(msg, sizeof(*nsh) + 6);
294 nsh = (struct gprs_ns_hdr *) msg->l2h;
295 nsh->pdu_type = NS_PDUT_UNITDATA;
296 nsh->data[0] = 0; /* sdu control */
297 nsh->data[1] = 0; /* msb bvci */
298 nsh->data[2] = 12; /* lsb bvci */
299 nsh->data[3] = 0xab; /* first data byte */
300 nsh->data[4] = 0xcd;
301 nsh->data[5] = 0xef;
302
303 return msg;
304}
305
306void test_unitdata(void *ctx)
307{
308 struct gprs_ns2_inst *nsi;
309 struct gprs_ns2_vc_bind *bind[2];
310 struct gprs_ns2_vc_bind *loopbind;
311 struct gprs_ns2_nse *nse;
312 struct gprs_ns2_vc *nsvc[2];
313 struct gprs_ns2_vc *loop[2];
314
315 struct msgb *msg, *other;
316 char idbuf[32];
317 int i;
318
319 printf("--- Testing unitdata test\n");
320 osmo_wqueue_clear(unitdata);
321 printf("---- Create NSE + Binds\n");
322 nsi = gprs_ns2_instantiate(ctx, ns_prim_cb, NULL);
323 bind[0] = dummy_bind(nsi, "bblock1");
324 bind[1] = dummy_bind(nsi, "bblock2");
325 loopbind = loopback_bind(nsi, "loopback");
Alexander Couzens138b96f2021-01-25 16:23:29 +0100326 nse = gprs_ns2_create_nse(nsi, 1004, GPRS_NS2_LL_UDP, GPRS_NS2_DIALECT_STATIC_RESETBLOCK);
Alexander Couzens8f215c92021-01-25 15:27:56 +0100327 OSMO_ASSERT(nse);
328
329 for (i=0; i<2; i++) {
330 printf("---- Create NSVC[%d]\n", i);
331 snprintf(idbuf, sizeof(idbuf), "NSE%05u-dummy-%i", nse->nsei, i);
Alexander Couzens138b96f2021-01-25 16:23:29 +0100332 nsvc[i] = ns2_vc_alloc(bind[i], nse, false, GPRS_NS2_VC_MODE_BLOCKRESET, idbuf);
Alexander Couzens8f215c92021-01-25 15:27:56 +0100333 loop[i] = loopback_nsvc(loopbind, nsvc[i]);
334 OSMO_ASSERT(nsvc[i]);
Alexander Couzens8dfc24c2021-01-25 16:09:23 +0100335 ns2_vc_fsm_start(nsvc[i]);
336 OSMO_ASSERT(!ns2_vc_is_unblocked(nsvc[i]));
Alexander Couzens8f215c92021-01-25 15:27:56 +0100337 ns2_tx_reset(loop[i], NS_CAUSE_OM_INTERVENTION);
338 ns2_tx_unblock(loop[i]);
Alexander Couzens8dfc24c2021-01-25 16:09:23 +0100339 OSMO_ASSERT(ns2_vc_is_unblocked(nsvc[i]));
Alexander Couzens8f215c92021-01-25 15:27:56 +0100340 }
341
342 /* both nsvcs are unblocked and alive */
343 printf("---- Send UNITDATA to NSVC[0]\n");
344 msg = generate_unitdata("test_unitdata");
345 ns2_recv_vc(nsvc[0], msg);
346 other = msgb_dequeue(&unitdata->msg_queue);
347 OSMO_ASSERT(msg == other);
348 other = msgb_dequeue(&unitdata->msg_queue);
349 OSMO_ASSERT(NULL == other);
350
351 printf("---- Send Block NSVC[0]\n");
352 ns2_vc_block(nsvc[0]);
353 ns2_tx_block_ack(loop[0]);
354
355 /* try to receive a unitdata - this should be dropped & freed by NS */
356 printf("---- Try to receive over blocked NSVC[0]\n");
357 ns2_recv_vc(nsvc[0], msg);
358 other = msgb_dequeue(&unitdata->msg_queue);
359 OSMO_ASSERT(NULL == other);
360
361 /* nsvc[1] should be still good */
362 printf("---- Receive over NSVC[1]\n");
363 msg = generate_unitdata("test_unitdata2");
364 ns2_recv_vc(nsvc[1], msg);
365 other = msgb_dequeue(&unitdata->msg_queue);
366 OSMO_ASSERT(msg == other);
367 msgb_free(msg);
368
369 gprs_ns2_free(nsi);
370 printf("--- Finish unitdata test\n");
371}
372
Alexander Couzens4f1128f2021-01-20 17:42:48 +0100373void test_mtu(void *ctx)
374{
375 struct gprs_ns2_inst *nsi;
376 struct gprs_ns2_vc_bind *bind[2];
377 struct gprs_ns2_vc_bind *loopbind;
378 struct gprs_ns2_nse *nse;
379 struct gprs_ns2_vc *nsvc[2];
380 struct gprs_ns2_vc *loop[2];
381
382 struct msgb *msg, *other;
383 char idbuf[32];
384 int i;
385
386 printf("--- Testing mtu test\n");
387 osmo_wqueue_clear(unitdata);
388 printf("---- Create NSE + Binds\n");
389 nsi = gprs_ns2_instantiate(ctx, ns_prim_cb, NULL);
390 bind[0] = dummy_bind(nsi, "bblock1");
391 bind[1] = dummy_bind(nsi, "bblock2");
392 loopbind = loopback_bind(nsi, "loopback");
393 nse = gprs_ns2_create_nse(nsi, 1004, GPRS_NS2_LL_UDP, GPRS_NS2_DIALECT_STATIC_RESETBLOCK);
394 OSMO_ASSERT(nse);
395
396 for (i=0; i<2; i++) {
397 printf("---- Create NSVC[%d]\n", i);
398 snprintf(idbuf, sizeof(idbuf), "NSE%05u-dummy-%i", nse->nsei, i);
399 nsvc[i] = ns2_vc_alloc(bind[i], nse, false, GPRS_NS2_VC_MODE_BLOCKRESET, idbuf);
400 loop[i] = loopback_nsvc(loopbind, nsvc[i]);
401 OSMO_ASSERT(nsvc[i]);
402 ns2_vc_fsm_start(nsvc[i]);
403 OSMO_ASSERT(!ns2_vc_is_unblocked(nsvc[i]));
404 ns2_tx_reset(loop[i], NS_CAUSE_OM_INTERVENTION);
405 ns2_tx_unblock(loop[i]);
406 OSMO_ASSERT(ns2_vc_is_unblocked(nsvc[i]));
407 }
408
409 /* both nsvcs are unblocked and alive */
410 printf("---- Send a small UNITDATA to NSVC[0]\n");
411 msg = generate_unitdata("test_unitdata");
412 ns2_recv_vc(nsvc[0], msg);
413 other = msgb_dequeue(&unitdata->msg_queue);
414 OSMO_ASSERT(msg == other);
415 other = msgb_dequeue(&unitdata->msg_queue);
416 OSMO_ASSERT(NULL == other);
417 msgb_free(msg);
418
419 printf("---- Check if got mtu reported\n");
420 /* 1b NS PDU type, 1b NS SDU control, 2b BVCI */
421 OSMO_ASSERT(last_nse_recovery.u.status.mtu == 123 - 4);
422
423 gprs_ns2_free(nsi);
424 printf("--- Finish unitdata test\n");
425}
Alexander Couzens8f215c92021-01-25 15:27:56 +0100426
Alexander Couzens1c8785d2020-12-17 06:58:53 +0100427int main(int argc, char **argv)
428{
429 void *ctx = talloc_named_const(NULL, 0, "gprs_ns2_test");
430 osmo_init_logging2(ctx, &info);
431 log_set_use_color(osmo_stderr_target, 0);
432 log_set_print_filename(osmo_stderr_target, 0);
433 log_set_print_filename(osmo_stderr_target, 0);
434 log_set_log_level(osmo_stderr_target, LOGL_INFO);
Alexander Couzens8f215c92021-01-25 15:27:56 +0100435 unitdata = talloc_zero(ctx, struct osmo_wqueue);
436 osmo_wqueue_init(unitdata, 100);
Alexander Couzens1c8785d2020-12-17 06:58:53 +0100437 setlinebuf(stdout);
438
439 printf("===== NS2 protocol test START\n");
440 test_nse_transfer_cap(ctx);
Alexander Couzens47afc422021-01-17 20:12:46 +0100441 test_block_unblock_nsvc(ctx);
Alexander Couzens8f215c92021-01-25 15:27:56 +0100442 test_unitdata(ctx);
Alexander Couzens4f1128f2021-01-20 17:42:48 +0100443 test_mtu(ctx);
Alexander Couzens1c8785d2020-12-17 06:58:53 +0100444 printf("===== NS2 protocol test END\n\n");
445
Alexander Couzense19b7962021-01-17 20:07:54 +0100446 talloc_free(ctx);
Alexander Couzens1c8785d2020-12-17 06:58:53 +0100447 exit(EXIT_SUCCESS);
448}