blob: f1945735f6b5f299348f71cb0da0b52d08131c38 [file] [log] [blame]
Harald Welte3b6fb082016-04-25 18:46:22 +02001#include <string.h>
2
3#include <osmocom/core/logging.h>
4#include <osmocom/core/utils.h>
5#include <osmocom/core/application.h>
6#include <osmocom/gsm/gsup.h>
7
8#define VERBOSE_FPRINTF(...)
9
10/* Tests for osmo_gsup_messages.c */
11
12#define TEST_IMSI_IE 0x01, 0x08, 0x21, 0x43, 0x65, 0x87, 0x09, 0x21, 0x43, 0xf5
13#define TEST_IMSI_STR "123456789012345"
14
15static void test_gsup_messages_dec_enc(void)
16{
17 int test_idx;
18 int rc;
19 uint8_t buf[1024];
20
21 static const uint8_t send_auth_info_req[] = {
22 0x08,
23 TEST_IMSI_IE
24 };
25
26 static const uint8_t send_auth_info_err[] = {
27 0x09,
28 TEST_IMSI_IE,
29 0x02, 0x01, 0x07 /* GPRS no allowed */
30 };
31
32 static const uint8_t send_auth_info_res[] = {
33 0x0a,
34 TEST_IMSI_IE,
35 0x03, 0x22, /* Auth tuple */
36 0x20, 0x10,
37 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
38 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
39 0x21, 0x04,
40 0x21, 0x22, 0x23, 0x24,
41 0x22, 0x08,
42 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
43 0x03, 0x22, /* Auth tuple */
44 0x20, 0x10,
45 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88,
46 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90,
47 0x21, 0x04,
48 0xa1, 0xa2, 0xa3, 0xa4,
49 0x22, 0x08,
50 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8,
51 };
52
53 static const uint8_t update_location_req[] = {
54 0x04,
55 TEST_IMSI_IE,
56 };
57
58 static const uint8_t update_location_err[] = {
59 0x05,
60 TEST_IMSI_IE,
61 0x02, 0x01, 0x07 /* GPRS no allowed */
62 };
63
64 static const uint8_t update_location_res[] = {
65 0x06,
66 TEST_IMSI_IE,
67 0x08, 0x07, /* MSISDN of the subscriber */
68 0x91, 0x94, 0x61, 0x46, 0x32, 0x24, 0x43,
69 0x09, 0x07, /* HLR-Number of the subscriber */
70 0x91, 0x83, 0x52, 0x38, 0x48, 0x83, 0x93,
71 0x04, 0x00, /* PDP info complete */
Holger Hans Peter Freythereb55c0d2017-07-07 16:53:30 +020072 0x05, 0x19,
Harald Welte3b6fb082016-04-25 18:46:22 +020073 0x10, 0x01, 0x01,
74 0x11, 0x02, 0xf1, 0x21, /* IPv4 */
75 0x12, 0x09, 0x04, 't', 'e', 's', 't', 0x03, 'a', 'p', 'n',
76 0x13, 0x01, 0x02,
Holger Hans Peter Freythereb55c0d2017-07-07 16:53:30 +020077 0x14, 0x02, 0xFF, 0x23,
Harald Welte3b6fb082016-04-25 18:46:22 +020078 0x05, 0x11,
79 0x10, 0x01, 0x02,
80 0x11, 0x02, 0xf1, 0x21, /* IPv4 */
81 0x12, 0x08, 0x03, 'f', 'o', 'o', 0x03, 'a', 'p', 'n',
Holger Hans Peter Freythereb55c0d2017-07-07 16:53:30 +020082 0x14, 0x02,
83 0xAE, 0xFF
Harald Welte3b6fb082016-04-25 18:46:22 +020084 };
85
86 static const uint8_t location_cancellation_req[] = {
87 0x1c,
88 TEST_IMSI_IE,
89 0x06, 0x01, 0x00,
90 };
91
92 static const uint8_t location_cancellation_err[] = {
93 0x1d,
94 TEST_IMSI_IE,
95 0x02, 0x01, 0x03 /* Illegal MS */
96 };
97
98 static const uint8_t location_cancellation_res[] = {
99 0x1e,
100 TEST_IMSI_IE,
101 };
102
103 static const uint8_t purge_ms_req[] = {
104 0x0c,
105 TEST_IMSI_IE,
106 };
107
108 static const uint8_t purge_ms_err[] = {
109 0x0d,
110 TEST_IMSI_IE,
111 0x02, 0x01, 0x03, /* Illegal MS */
112 };
113
114 static const uint8_t purge_ms_res[] = {
115 0x0e,
116 TEST_IMSI_IE,
117 0x07, 0x00,
118 };
119
Neels Hofmeyrabb23692017-02-21 15:53:20 +0100120 static const uint8_t send_auth_info_res_umts[] = {
121 0x0a,
122 TEST_IMSI_IE,
123 0x03, 0x62, /* Auth tuple */
124 0x20, 0x10, /* rand */
125 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
126 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
127 0x21, 0x04, /* sres */
128 0x21, 0x22, 0x23, 0x24,
129 0x22, 0x08, /* kc */
130 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
131 0x23, 0x10, /* IK (UMTS) */
132 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
133 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
134 0x24, 0x10, /* CK (UMTS) */
135 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
136 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
137 0x25, 0x10, /* AUTN (UMTS) */
138 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
139 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
Neels Hofmeyrbd9de2f2017-02-21 20:17:35 +0100140 0x27, 0x08, /* RES (UMTS) */
Neels Hofmeyrabb23692017-02-21 15:53:20 +0100141 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
Neels Hofmeyrbd9de2f2017-02-21 20:17:35 +0100142 0x03, 0x62, /* Auth tuple */
Neels Hofmeyrabb23692017-02-21 15:53:20 +0100143 0x20, 0x10, /* rand */
144 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8,
145 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0x10,
146 0x21, 0x04, /* sres */
147 0xb1, 0xb2, 0xb3, 0xb4,
148 0x22, 0x08, /* kc */
149 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8,
150 0x23, 0x10, /* IK (UMTS) */
151 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
152 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xd0,
153 0x24, 0x10, /* CK (UMTS) */
154 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8,
155 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xe0,
156 0x25, 0x10, /* AUTN (UMTS) */
157 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
158 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0xf0,
Neels Hofmeyrbd9de2f2017-02-21 20:17:35 +0100159 0x27, 0x08, /* RES (UMTS) */
Neels Hofmeyrabb23692017-02-21 15:53:20 +0100160 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
161 };
162
163 static const uint8_t send_auth_info_req_auts[] = {
164 0x08,
165 TEST_IMSI_IE,
Neels Hofmeyrbd9de2f2017-02-21 20:17:35 +0100166 0x26, 0x0e, /* AUTS (UMTS) */
Neels Hofmeyrabb23692017-02-21 15:53:20 +0100167 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
168 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
Neels Hofmeyrbd9de2f2017-02-21 20:17:35 +0100169 0x20, 0x10, /* rand */
Neels Hofmeyrabb23692017-02-21 15:53:20 +0100170 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
171 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
172 };
173
Vadim Yanitskiy72696042018-04-07 02:34:55 +0700174 static const uint8_t dummy_session_ies[] = {
175 0x2b, /* Dummy value, we only interested in IE coding */
176 TEST_IMSI_IE,
177
178 /* Session ID and state */
179 0x30, 0x04, 0xde, 0xad, 0xbe, 0xef,
180 0x31, 0x01, 0x01,
181 };
182
Vadim Yanitskiy36c7b332018-03-31 05:23:09 +0700183 static const uint8_t send_ussd_req[] = {
184 0x20, /* OSMO_GSUP_MSGT_PROC_SS_REQUEST */
185 TEST_IMSI_IE,
186
187 /* Session ID and state */
188 0x30, 0x04, 0xde, 0xad, 0xbe, 0xef,
189 0x31, 0x01, 0x01,
190
191 /* SS/USSD information IE */
192 0x35, 0x14,
193 /* ASN.1 encoded MAP payload */
194 0xa1, 0x12,
195 0x02, 0x01, /* Component: invoke */
196 0x01, /* invokeID = 1 */
197 /* opCode: processUnstructuredSS-Request */
198 0x02, 0x01, 0x3b, 0x30, 0x0a, 0x04, 0x01, 0x0f,
199 0x04, 0x05, 0xaa, 0x18, 0x0c, 0x36, 0x02,
200 };
201
202 static const uint8_t send_ussd_res[] = {
203 0x22, /* OSMO_GSUP_MSGT_PROC_SS_RESULT */
204 TEST_IMSI_IE,
205
206 /* Session ID and state */
207 0x30, 0x04, 0xde, 0xad, 0xbe, 0xef,
208 0x31, 0x01, 0x03,
209
210 /* SS/USSD information IE */
211 0x35, 0x08,
212 /* ASN.1 encoded MAP payload */
213 0xa3, 0x06,
214 0x02, 0x01, /* Component: returnError */
215 0x01, /* invokeID = 1 */
216 /* localValue: unknownAlphabet */
217 0x02, 0x01, 0x47,
218 };
219
Vadim Yanitskiyc2628312018-09-25 23:03:13 +0700220 static const uint8_t send_mo_forward_sm_req[] = {
221 0x24, /* OSMO_GSUP_MSGT_MO_FORWARD_SM_REQUEST */
222 TEST_IMSI_IE,
223
224 /* SM related IEs */
225 0x40, 0x01, /* SM-RP-MR (Message Reference) */
226 0xfa,
227 0x41, 0x08, /* SM-RP-DA (Destination Address) */
228 0x03, /* SMSC address */
229 0x91, 0x52, 0x75, 0x47, 0x99, 0x09, 0x82,
230 0x42, 0x01, /* SM-RP-OA (Originating Address) */
231 0xff, /* Special case: noSM-RP-OA */
232 0x43, 0x04, /* SM-RP-UI (TPDU) */
233 0xde, 0xad, 0xbe, 0xef,
234 };
235
236 static const uint8_t send_mt_forward_sm_req[] = {
237 0x28, /* OSMO_GSUP_MSGT_MT_FORWARD_SM_REQUEST */
238 TEST_IMSI_IE,
239
240 /* SM related IEs */
241 0x40, 0x01, /* SM-RP-MR (Message Reference) */
242 0xfa,
243 0x41, 0x09, /* SM-RP-DA (Destination Address) */
244 0x01, /* IMSI */
245 0x21, 0x43, 0x65, 0x87, 0x09, 0x21, 0x43, 0xf5,
246 0x42, 0x08, /* SM-RP-OA (Originating Address) */
247 0x03, /* SMSC address */
248 0x91, 0x52, 0x75, 0x47, 0x99, 0x09, 0x82,
249 0x43, 0x04, /* SM-RP-UI (TPDU) */
250 0xde, 0xad, 0xbe, 0xef,
251 0x45, 0x01, /* SM-RP-MMS (More Messages to Send) */
252 0x01,
253 };
254
255 static const uint8_t send_mo_mt_forward_sm_err[] = {
256 0x25, /* OSMO_GSUP_MSGT_MO_FORWARD_SM_ERROR */
257 TEST_IMSI_IE,
258
259 /* Session related IEs */
260 0x30, 0x04, /* Session ID */
261 0xde, 0xad, 0xbe, 0xef,
262 0x31, 0x01, /* Session state (END) */
263 0x03,
264
265 /* SM related IEs */
266 0x40, 0x01, /* SM-RP-MR (Message Reference) */
267 0xfa,
268 0x44, 0x01, /* SM-RP-Cause value */
269 0xaf,
270 };
271
272 static const uint8_t send_mo_mt_forward_sm_rsp[] = {
273 0x2a, /* OSMO_GSUP_MSGT_MT_FORWARD_SM_RESULT */
274 TEST_IMSI_IE,
275
276 /* SM related IEs */
277 0x40, 0x01, /* SM-RP-MR (Message Reference) */
278 0xfa,
279 0x43, 0x04, /* SM-RP-UI (TPDU) */
280 0xde, 0xad, 0xbe, 0xef,
281 };
282
Vadim Yanitskiyf9ee8da2018-11-13 02:06:15 +0700283 static const uint8_t send_ready_for_sm_ind[] = {
284 0x2c, /* OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST */
285 TEST_IMSI_IE,
286
287 /* SM related IEs */
288 0x46, 0x01, /* Alert reason */
289 0x02, /* Memory Available (SMMA) */
290 };
291
Oliver Smith10db2812018-12-14 16:14:34 +0100292 static const uint8_t send_check_imei_req[] = {
293 0x30, /* OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST */
294 TEST_IMSI_IE,
295
296 /* imei */
297 0x50, 0x09,
298 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42,
299 };
300
301 static const uint8_t send_check_imei_err[] = {
302 0x31, /* OSMO_GSUP_MSGT_CHECK_IMEI_ERROR */
303 TEST_IMSI_IE,
304
305 /* cause */
306 0x02, 0x01,
307 0x60, /* GMM_CAUSE_INV_MAND_INFO */
308 };
309
310 static const uint8_t send_check_imei_res[] = {
311 0x32, /* OSMO_GSUP_MSGT_CHECK_IMEI_RESULT */
312 TEST_IMSI_IE,
313
314 /* imei_result */
315 0x51, 0x01,
316 0x00, /* OSMO_GSUP_IMEI_RESULT_ACK */
317 };
318
Harald Welte3b6fb082016-04-25 18:46:22 +0200319 static const struct test {
320 char *name;
321 const uint8_t *data;
322 size_t data_len;
323 } test_messages[] = {
324 {"Send Authentication Info Request",
325 send_auth_info_req, sizeof(send_auth_info_req)},
326 {"Send Authentication Info Error",
327 send_auth_info_err, sizeof(send_auth_info_err)},
328 {"Send Authentication Info Result",
329 send_auth_info_res, sizeof(send_auth_info_res)},
330 {"Update Location Request",
331 update_location_req, sizeof(update_location_req)},
332 {"Update Location Error",
333 update_location_err, sizeof(update_location_err)},
334 {"Update Location Result",
335 update_location_res, sizeof(update_location_res)},
336 {"Location Cancellation Request",
337 location_cancellation_req, sizeof(location_cancellation_req)},
338 {"Location Cancellation Error",
339 location_cancellation_err, sizeof(location_cancellation_err)},
340 {"Location Cancellation Result",
341 location_cancellation_res, sizeof(location_cancellation_res)},
342 {"Purge MS Request",
343 purge_ms_req, sizeof(purge_ms_req)},
344 {"Purge MS Error",
345 purge_ms_err, sizeof(purge_ms_err)},
346 {"Purge MS Result",
347 purge_ms_res, sizeof(purge_ms_res)},
Neels Hofmeyrabb23692017-02-21 15:53:20 +0100348 {"Send Authentication Info Result with IK, CK, AUTN and RES (UMTS)",
Neels Hofmeyrbd9de2f2017-02-21 20:17:35 +0100349 send_auth_info_res_umts, sizeof(send_auth_info_res_umts)},
Neels Hofmeyrabb23692017-02-21 15:53:20 +0100350 {"Send Authentication Info Request with AUTS and RAND (UMTS)",
351 send_auth_info_req_auts, sizeof(send_auth_info_req_auts)},
Vadim Yanitskiy72696042018-04-07 02:34:55 +0700352 {"Dummy message with session IEs",
353 dummy_session_ies, sizeof(dummy_session_ies)},
Vadim Yanitskiy36c7b332018-03-31 05:23:09 +0700354 {"SS/USSD processUnstructuredSS-Request / Invoke",
355 send_ussd_req, sizeof(send_ussd_req)},
356 {"SS/USSD processUnstructuredSS-Request / ReturnResult",
357 send_ussd_res, sizeof(send_ussd_res)},
Vadim Yanitskiyc2628312018-09-25 23:03:13 +0700358 {"MO-ForwardSM (MSC -> SMSC) Request",
359 send_mo_forward_sm_req, sizeof(send_mo_forward_sm_req)},
360 {"MT-ForwardSM (MSC -> SMSC) Request",
361 send_mt_forward_sm_req, sizeof(send_mt_forward_sm_req)},
362 {"MO-/MT-ForwardSM Response",
363 send_mo_mt_forward_sm_rsp, sizeof(send_mo_mt_forward_sm_rsp)},
364 {"MO-/MT-ForwardSM Error",
365 send_mo_mt_forward_sm_err, sizeof(send_mo_mt_forward_sm_err)},
Vadim Yanitskiyf9ee8da2018-11-13 02:06:15 +0700366 {"ReadyForSM (MSC -> SMSC) Indication",
367 send_ready_for_sm_ind, sizeof(send_ready_for_sm_ind)},
Oliver Smith10db2812018-12-14 16:14:34 +0100368 {"Check IMEI Request",
369 send_check_imei_req, sizeof(send_check_imei_req)},
370 {"Check IMEI Error",
371 send_check_imei_err, sizeof(send_check_imei_err)},
372 {"Check IMEI Result",
373 send_check_imei_res, sizeof(send_check_imei_res)},
Harald Welte3b6fb082016-04-25 18:46:22 +0200374 };
375
376 printf("Test GSUP message decoding/encoding\n");
377
378 for (test_idx = 0; test_idx < ARRAY_SIZE(test_messages); test_idx++) {
379 const struct test *t = &test_messages[test_idx];
380 struct osmo_gsup_message gm = {0};
381 struct msgb *msg = msgb_alloc(4096, "gsup_test");
Max49382722018-01-22 15:15:06 +0100382 bool passed = true;
Harald Welte3b6fb082016-04-25 18:46:22 +0200383
384 printf(" Testing %s\n", t->name);
385
386 rc = osmo_gsup_decode(t->data, t->data_len, &gm);
Max49382722018-01-22 15:15:06 +0100387 if (rc < 0)
388 passed = false;
Harald Welte3b6fb082016-04-25 18:46:22 +0200389
Max80f4c4e2018-01-24 12:33:05 +0100390 rc = osmo_gsup_encode(msg, &gm);
391 if (rc < 0)
392 passed = false;
Harald Welte3b6fb082016-04-25 18:46:22 +0200393
394 fprintf(stderr, " generated message: %s\n", msgb_hexdump(msg));
395 fprintf(stderr, " original message: %s\n", osmo_hexdump(t->data, t->data_len));
396 fprintf(stderr, " IMSI: %s\n", gm.imsi);
Harald Welte3b6fb082016-04-25 18:46:22 +0200397
Max49382722018-01-22 15:15:06 +0100398 if (strcmp(gm.imsi, TEST_IMSI_STR) != 0 ||
399 msgb_length(msg) != t->data_len ||
400 memcmp(msgb_data(msg), t->data, t->data_len) != 0)
401 passed = false;
402
403 if (passed)
404 printf(" %s OK\n", t->name);
405 else
406 printf(" %s FAILED: %d<%s> [%u,%u,%zu,%u]\n",
407 t->name, rc, strerror(-rc),
408 strcmp(gm.imsi, TEST_IMSI_STR),
409 msgb_length(msg), t->data_len,
410 memcmp(msgb_data(msg), t->data, t->data_len));
Harald Welte3b6fb082016-04-25 18:46:22 +0200411 msgb_free(msg);
412 }
413
414 /* simple truncation test */
415 for (test_idx = 0; test_idx < ARRAY_SIZE(test_messages); test_idx++) {
416 int j;
417 const struct test *t = &test_messages[test_idx];
418 int ie_end = t->data_len;
419 struct osmo_gsup_message gm = {0};
420 int counter = 0;
421 int parse_err = 0;
422
423 for (j = t->data_len - 1; j >= 0; --j) {
424 rc = osmo_gsup_decode(t->data, j, &gm);
425 counter += 1;
426
427 VERBOSE_FPRINTF(stderr,
428 " partial message decoding: "
429 "orig_len = %d, trunc = %d, rc = %d, ie_end = %d\n",
430 t->data_len, j, rc, ie_end);
431 if (rc >= 0) {
432 VERBOSE_FPRINTF(stderr,
433 " remaing partial message: %s\n",
434 osmo_hexdump(t->data + j, ie_end - j));
435
436 OSMO_ASSERT(j <= ie_end - 2);
Oliver Smith19742402018-12-21 10:18:28 +0100437 OSMO_ASSERT(t->data[j+0] < _OSMO_GSUP_IEI_END_MARKER);
Harald Welte3b6fb082016-04-25 18:46:22 +0200438 OSMO_ASSERT(t->data[j+1] <= ie_end - j - 2);
439
440 ie_end = j;
441 } else {
442 parse_err += 1;
443 }
444 }
445
446 fprintf(stderr,
447 " message %d: tested %d truncations, %d parse failures\n",
448 test_idx, counter, parse_err);
449 }
450
Neels Hofmeyrbd9de2f2017-02-21 20:17:35 +0100451 /* Don't log thousands of message modification errors */
452 LOGP(DLGSUP, LOGL_NOTICE, "Stopping DLGSUP logging\n");
453 log_set_category_filter(osmo_stderr_target, DLGSUP, 0, 0);
454
Harald Welte3b6fb082016-04-25 18:46:22 +0200455 /* message modification test (relies on ASAN or valgrind being used) */
456 for (test_idx = 0; test_idx < ARRAY_SIZE(test_messages); test_idx++) {
457 int j;
458 const struct test *t = &test_messages[test_idx];
459 struct osmo_gsup_message gm = {0};
460 uint8_t val;
461 int counter = 0;
462 int parse_err = 0;
463
464 OSMO_ASSERT(sizeof(buf) >= t->data_len);
465
466 for (j = t->data_len - 1; j >= 0; --j) {
467 memcpy(buf, t->data, t->data_len);
468 val = 0;
469 do {
470 VERBOSE_FPRINTF(stderr,
471 "t = %d, len = %d, val = %d\n",
472 test_idx, j, val);
473 buf[j] = val;
474 rc = osmo_gsup_decode(buf, t->data_len, &gm);
475 counter += 1;
476 if (rc < 0)
477 parse_err += 1;
478
479 val += 1;
480 } while (val != (uint8_t)256);
481 }
482
483 fprintf(stderr,
484 " message %d: tested %d modifications, %d parse failures\n",
485 test_idx, counter, parse_err);
486 }
487}
488
489const struct log_info_cat default_categories[] = {
Harald Welte3b6fb082016-04-25 18:46:22 +0200490};
491
492static struct log_info info = {
493 .cat = default_categories,
494 .num_cat = ARRAY_SIZE(default_categories),
495};
496
497int main(int argc, char **argv)
498{
Neels Hofmeyra829b452018-04-05 03:02:35 +0200499 void *ctx = talloc_named_const(NULL, 0, "gsup_test");
500 osmo_init_logging2(ctx, &info);
Neels Hofmeyrbd9de2f2017-02-21 20:17:35 +0100501 log_set_print_filename(osmo_stderr_target, 0);
502 log_set_print_timestamp(osmo_stderr_target, 0);
503 log_set_use_color(osmo_stderr_target, 0);
504 log_set_print_category(osmo_stderr_target, 1);
Harald Welte3b6fb082016-04-25 18:46:22 +0200505
506 test_gsup_messages_dec_enc();
507
508 printf("Done.\n");
509 return EXIT_SUCCESS;
510}