blob: 40e2475ba3622d164f1f0a9203d036e970261002 [file] [log] [blame]
Holger Hans Peter Freyther0b8f69d2010-06-15 18:45:38 +08001/*
2 * BSC NAT Message filtering
3 *
4 * (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
Holger Hans Peter Freytherdf6143a2010-06-15 18:46:56 +08005 * (C) 2010 by On-Waves
Holger Hans Peter Freyther0b8f69d2010-06-15 18:45:38 +08006 *
7 * All Rights Reserved
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 *
23 */
24
25
26#include <openbsc/debug.h>
27#include <openbsc/gsm_data.h>
28#include <openbsc/bsc_nat.h>
29
Holger Hans Peter Freyther38f7c752010-06-15 18:48:36 +080030#include <osmocore/talloc.h>
31
Holger Hans Peter Freyther0b8f69d2010-06-15 18:45:38 +080032#include <stdio.h>
33
34/* test messages for ipa */
35static u_int8_t ipa_id[] = {
36 0x00, 0x01, 0xfe, 0x06,
37};
38
39/* SCCP messages are below */
40static u_int8_t gsm_reset[] = {
41 0x00, 0x12, 0xfd,
42 0x09, 0x00, 0x03, 0x05, 0x07, 0x02, 0x42, 0xfe,
43 0x02, 0x42, 0xfe, 0x06, 0x00, 0x04, 0x30, 0x04,
44 0x01, 0x20,
45};
46
47static const u_int8_t gsm_reset_ack[] = {
48 0x00, 0x13, 0xfd,
49 0x09, 0x00, 0x03, 0x07, 0x0b, 0x04, 0x43, 0x01,
50 0x00, 0xfe, 0x04, 0x43, 0x5c, 0x00, 0xfe, 0x03,
51 0x00, 0x01, 0x31,
52};
53
54static const u_int8_t gsm_paging[] = {
55 0x00, 0x20, 0xfd,
56 0x09, 0x00, 0x03, 0x07, 0x0b, 0x04, 0x43, 0x01,
57 0x00, 0xfe, 0x04, 0x43, 0x5c, 0x00, 0xfe, 0x10,
58 0x00, 0x0e, 0x52, 0x08, 0x08, 0x29, 0x47, 0x10,
59 0x02, 0x01, 0x31, 0x97, 0x61, 0x1a, 0x01, 0x06,
60};
61
62/* BSC -> MSC connection open */
63static const u_int8_t bssmap_cr[] = {
64 0x00, 0x2c, 0xfd,
65 0x01, 0x01, 0x02, 0x03, 0x02, 0x02, 0x04, 0x02,
66 0x42, 0xfe, 0x0f, 0x1f, 0x00, 0x1d, 0x57, 0x05,
67 0x08, 0x00, 0x72, 0xf4, 0x80, 0x20, 0x12, 0xc3,
68 0x50, 0x17, 0x10, 0x05, 0x24, 0x11, 0x03, 0x33,
69 0x19, 0xa2, 0x08, 0x29, 0x47, 0x10, 0x02, 0x01,
70 0x31, 0x97, 0x61, 0x00
71};
72
73/* MSC -> BSC connection confirm */
74static const u_int8_t bssmap_cc[] = {
75 0x00, 0x0a, 0xfd,
76 0x02, 0x01, 0x02, 0x03, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00,
77};
78
79/* MSC -> BSC released */
80static const u_int8_t bssmap_released[] = {
81 0x00, 0x0e, 0xfd,
82 0x04, 0x00, 0x00, 0x03, 0x01, 0x02, 0x03, 0x00, 0x01, 0x0f,
83 0x02, 0x23, 0x42, 0x00,
84};
85
86/* BSC -> MSC released */
87static const u_int8_t bssmap_release_complete[] = {
88 0x00, 0x07, 0xfd,
89 0x05, 0x01, 0x02, 0x03, 0x00, 0x00, 0x03
90};
91
Holger Hans Peter Freyther0a6f62f2010-04-06 10:22:01 +020092/* both directions IT timer */
93static const u_int8_t connnection_it[] = {
94 0x00, 0x0b, 0xfd,
95 0x10, 0x01, 0x02, 0x03, 0x01, 0x02, 0x03,
96 0x00, 0x00, 0x00, 0x00,
97};
98
Holger Hans Peter Freythera128d912010-04-01 08:47:12 +020099/* MGCP wrap... */
100static const u_int8_t mgcp_msg[] = {
101 0x00, 0x03, 0xfc,
102 0x20, 0x20, 0x20,
103};
104
Holger Hans Peter Freyther0b8f69d2010-06-15 18:45:38 +0800105struct filter_result {
106 const u_int8_t *data;
107 const u_int16_t length;
Holger Hans Peter Freyther1d6fb182010-01-30 11:53:30 +0100108 const int dir;
Holger Hans Peter Freyther0b8f69d2010-06-15 18:45:38 +0800109 const int result;
110};
111
112static const struct filter_result results[] = {
113 {
114 .data = ipa_id,
115 .length = ARRAY_SIZE(ipa_id),
Holger Hans Peter Freyther1d6fb182010-01-30 11:53:30 +0100116 .dir = DIR_MSC,
117 .result = 1,
Holger Hans Peter Freyther0b8f69d2010-06-15 18:45:38 +0800118 },
119 {
120 .data = gsm_reset,
121 .length = ARRAY_SIZE(gsm_reset),
Holger Hans Peter Freyther1d6fb182010-01-30 11:53:30 +0100122 .dir = DIR_MSC,
123 .result = 1,
Holger Hans Peter Freyther0b8f69d2010-06-15 18:45:38 +0800124 },
125 {
126 .data = gsm_reset_ack,
127 .length = ARRAY_SIZE(gsm_reset_ack),
Holger Hans Peter Freyther1d6fb182010-01-30 11:53:30 +0100128 .dir = DIR_BSC,
129 .result = 1,
Holger Hans Peter Freyther0b8f69d2010-06-15 18:45:38 +0800130 },
131 {
132 .data = gsm_paging,
133 .length = ARRAY_SIZE(gsm_paging),
Holger Hans Peter Freyther1d6fb182010-01-30 11:53:30 +0100134 .dir = DIR_BSC,
135 .result = 0,
Holger Hans Peter Freyther0b8f69d2010-06-15 18:45:38 +0800136 },
137 {
138 .data = bssmap_cr,
139 .length = ARRAY_SIZE(bssmap_cr),
Holger Hans Peter Freyther1d6fb182010-01-30 11:53:30 +0100140 .dir = DIR_MSC,
141 .result = 0,
Holger Hans Peter Freyther0b8f69d2010-06-15 18:45:38 +0800142 },
143 {
144 .data = bssmap_cc,
145 .length = ARRAY_SIZE(bssmap_cc),
Holger Hans Peter Freyther1d6fb182010-01-30 11:53:30 +0100146 .dir = DIR_BSC,
147 .result = 0,
Holger Hans Peter Freyther0b8f69d2010-06-15 18:45:38 +0800148 },
149 {
150 .data = bssmap_released,
151 .length = ARRAY_SIZE(bssmap_released),
Holger Hans Peter Freyther1d6fb182010-01-30 11:53:30 +0100152 .dir = DIR_MSC,
153 .result = 0,
Holger Hans Peter Freyther0b8f69d2010-06-15 18:45:38 +0800154 },
155 {
156 .data = bssmap_release_complete,
157 .length = ARRAY_SIZE(bssmap_release_complete),
Holger Hans Peter Freyther1d6fb182010-01-30 11:53:30 +0100158 .dir = DIR_BSC,
159 .result = 0,
Holger Hans Peter Freyther0b8f69d2010-06-15 18:45:38 +0800160 },
Holger Hans Peter Freythera128d912010-04-01 08:47:12 +0200161 {
162 .data = mgcp_msg,
163 .length = ARRAY_SIZE(mgcp_msg),
164 .dir = DIR_MSC,
165 .result = 0,
166 },
Holger Hans Peter Freyther0a6f62f2010-04-06 10:22:01 +0200167 {
168 .data = connnection_it,
169 .length = ARRAY_SIZE(connnection_it),
170 .dir = DIR_BSC,
171 .result = 0,
172 },
173 {
174 .data = connnection_it,
175 .length = ARRAY_SIZE(connnection_it),
176 .dir = DIR_MSC,
177 .result = 0,
178 },
Holger Hans Peter Freyther0b8f69d2010-06-15 18:45:38 +0800179};
180
Holger Hans Peter Freyther38f7c752010-06-15 18:48:36 +0800181static void test_filter(void)
Holger Hans Peter Freyther0b8f69d2010-06-15 18:45:38 +0800182{
183 int i;
184
185
186 /* start testinh with proper messages */
Holger Hans Peter Freyther38f7c752010-06-15 18:48:36 +0800187 fprintf(stderr, "Testing BSS Filtering.\n");
Holger Hans Peter Freyther0b8f69d2010-06-15 18:45:38 +0800188 for (i = 0; i < ARRAY_SIZE(results); ++i) {
189 int result;
190 struct bsc_nat_parsed *parsed;
191 struct msgb *msg = msgb_alloc(4096, "test-message");
192
193 fprintf(stderr, "Going to test item: %d\n", i);
194 memcpy(msg->data, results[i].data, results[i].length);
195 msg->l2h = msgb_put(msg, results[i].length);
196
197 parsed = bsc_nat_parse(msg);
198 if (!parsed) {
199 fprintf(stderr, "FAIL: Failed to parse the message\n");
200 continue;
201 }
202
Holger Hans Peter Freyther1d6fb182010-01-30 11:53:30 +0100203 result = bsc_nat_filter_ipa(results[i].dir, msg, parsed);
Holger Hans Peter Freyther0b8f69d2010-06-15 18:45:38 +0800204 if (result != results[i].result) {
205 fprintf(stderr, "FAIL: Not the expected result got: %d wanted: %d\n",
206 result, results[i].result);
207 }
208
209 msgb_free(msg);
210 }
Holger Hans Peter Freyther38f7c752010-06-15 18:48:36 +0800211}
Holger Hans Peter Freyther0b8f69d2010-06-15 18:45:38 +0800212
Holger Hans Peter Freyther38f7c752010-06-15 18:48:36 +0800213#include "bsc_data.c"
214
215static void copy_to_msg(struct msgb *msg, const u_int8_t *data, unsigned int length)
216{
217 msgb_reset(msg);
218 msg->l2h = msgb_put(msg, length);
219 memcpy(msg->l2h, data, msgb_l2len(msg));
220}
221
222#define VERIFY(con_found, con, msg, ver, str) \
Holger Hans Peter Freyther49c7fb52010-06-15 18:48:55 +0800223 if (!con_found || con_found->bsc != con) { \
Holger Hans Peter Freyther72ba1622010-06-15 18:48:44 +0800224 fprintf(stderr, "Failed to find the con: %p\n", con_found); \
Holger Hans Peter Freyther38f7c752010-06-15 18:48:36 +0800225 abort(); \
226 } \
227 if (memcmp(msg->data, ver, sizeof(ver)) != 0) { \
228 fprintf(stderr, "Failed to patch the %s msg.\n", str); \
229 abort(); \
230 }
231
232/* test conn tracking once */
233static void test_contrack()
234{
235 int rc;
236 struct bsc_nat *nat;
Holger Hans Peter Freyther49c7fb52010-06-15 18:48:55 +0800237 struct bsc_connection *con;
238 struct sccp_connections *con_found;
Holger Hans Peter Freyther38f7c752010-06-15 18:48:36 +0800239 struct bsc_nat_parsed *parsed;
240 struct msgb *msg;
241
242 fprintf(stderr, "Testing connection tracking.\n");
243 nat = bsc_nat_alloc();
244 con = bsc_connection_alloc(nat);
245 msg = msgb_alloc(4096, "test");
246
247 /* 1.) create a connection */
248 copy_to_msg(msg, bsc_cr, sizeof(bsc_cr));
249 parsed = bsc_nat_parse(msg);
250 con_found = patch_sccp_src_ref_to_msc(msg, parsed, nat);
251 if (con_found != NULL) {
Holger Hans Peter Freyther72ba1622010-06-15 18:48:44 +0800252 fprintf(stderr, "Con should not exist %p\n", con_found);
Holger Hans Peter Freyther38f7c752010-06-15 18:48:36 +0800253 abort();
254 }
255 rc = create_sccp_src_ref(con, msg, parsed);
256 if (rc != 0) {
257 fprintf(stderr, "Failed to create a ref\n");
258 abort();
259 }
260 con_found = patch_sccp_src_ref_to_msc(msg, parsed, nat);
Holger Hans Peter Freyther49c7fb52010-06-15 18:48:55 +0800261 if (!con_found || con_found->bsc != con) {
Holger Hans Peter Freyther72ba1622010-06-15 18:48:44 +0800262 fprintf(stderr, "Failed to find the con: %p\n", con_found);
Holger Hans Peter Freyther38f7c752010-06-15 18:48:36 +0800263 abort();
264 }
265 if (memcmp(msg->data, bsc_cr_patched, sizeof(bsc_cr_patched)) != 0) {
266 fprintf(stderr, "Failed to patch the BSC CR msg.\n");
267 abort();
268 }
269 talloc_free(parsed);
270
271 /* 2.) get the cc */
272 copy_to_msg(msg, msc_cc, sizeof(msc_cc));
273 parsed = bsc_nat_parse(msg);
Holger Hans Peter Freyther49c7fb52010-06-15 18:48:55 +0800274 con_found = patch_sccp_src_ref_to_bsc(msg, parsed, nat);
275 VERIFY(con_found, con, msg, msc_cc_patched, "MSC CC");
276 if (update_sccp_src_ref(con_found, parsed) != 0) {
Holger Hans Peter Freyther38f7c752010-06-15 18:48:36 +0800277 fprintf(stderr, "Failed to update the SCCP con.\n");
278 abort();
279 }
Holger Hans Peter Freyther38f7c752010-06-15 18:48:36 +0800280
281 /* 3.) send some data */
282 copy_to_msg(msg, bsc_dtap, sizeof(bsc_dtap));
283 parsed = bsc_nat_parse(msg);
284 con_found = patch_sccp_src_ref_to_msc(msg, parsed, nat);
285 VERIFY(con_found, con, msg, bsc_dtap_patched, "BSC DTAP");
286
287 /* 4.) receive some data */
288 copy_to_msg(msg, msc_dtap, sizeof(msc_dtap));
289 parsed = bsc_nat_parse(msg);
290 con_found = patch_sccp_src_ref_to_bsc(msg, parsed, nat);
291 VERIFY(con_found, con, msg, msc_dtap_patched, "MSC DTAP");
292
293 /* 5.) close the connection */
294 copy_to_msg(msg, msc_rlsd, sizeof(msc_rlsd));
295 parsed = bsc_nat_parse(msg);
296 con_found = patch_sccp_src_ref_to_bsc(msg, parsed, nat);
297 VERIFY(con_found, con, msg, msc_rlsd_patched, "MSC RLSD");
298
299 /* 6.) confirm the connection close */
300 copy_to_msg(msg, bsc_rlc, sizeof(bsc_rlc));
301 parsed = bsc_nat_parse(msg);
302 con_found = patch_sccp_src_ref_to_msc(msg, parsed, nat);
Holger Hans Peter Freyther49c7fb52010-06-15 18:48:55 +0800303 if (!con_found || con_found->bsc != con) {
Holger Hans Peter Freyther72ba1622010-06-15 18:48:44 +0800304 fprintf(stderr, "Failed to find the con: %p\n", con_found);
Holger Hans Peter Freyther38f7c752010-06-15 18:48:36 +0800305 abort();
306 }
307 if (memcmp(msg->data, bsc_rlc_patched, sizeof(bsc_rlc_patched)) != 0) {
308 fprintf(stderr, "Failed to patch the BSC CR msg.\n");
309 abort();
310 }
311 remove_sccp_src_ref(con, msg, parsed);
Holger Hans Peter Freyther9d518552010-04-05 21:44:51 +0200312 talloc_free(parsed);
313
314 copy_to_msg(msg, bsc_rlc, sizeof(bsc_rlc));
315 parsed = bsc_nat_parse(msg);
Holger Hans Peter Freyther38f7c752010-06-15 18:48:36 +0800316 con_found = patch_sccp_src_ref_to_msc(msg, parsed, nat);
317
318 /* verify that it is gone */
319 if (con_found != NULL) {
Holger Hans Peter Freyther72ba1622010-06-15 18:48:44 +0800320 fprintf(stderr, "Con should be gone. %p\n", con_found);
Holger Hans Peter Freyther38f7c752010-06-15 18:48:36 +0800321 abort();
322 }
323 talloc_free(parsed);
324
325
326 talloc_free(nat);
327 msgb_free(msg);
328}
329
Holger Hans Peter Freyther04fd9922010-03-30 06:51:53 +0200330static void test_paging(void)
331{
332 struct bsc_nat *nat;
333 struct bsc_connection *con;
334 struct bsc_nat_parsed *parsed;
Holger Hans Peter Freyther47dd4942010-04-06 15:11:34 +0200335 struct bsc_config cfg;
Holger Hans Peter Freyther04fd9922010-03-30 06:51:53 +0200336 struct msgb *msg;
337
338 fprintf(stderr, "Testing paging by lac.\n");
339
340 nat = bsc_nat_alloc();
341 con = bsc_connection_alloc(nat);
Holger Hans Peter Freyther47dd4942010-04-06 15:11:34 +0200342 con->cfg = &cfg;
343 cfg.lac = 23;
Holger Hans Peter Freyther04fd9922010-03-30 06:51:53 +0200344 con->authenticated = 1;
345 llist_add(&con->list_entry, &nat->bsc_connections);
346 msg = msgb_alloc(4096, "test");
347
348 /* Test completely bad input */
349 copy_to_msg(msg, paging_by_lac_cmd, sizeof(paging_by_lac_cmd));
350 if (bsc_nat_find_bsc(nat, msg) != 0) {
351 fprintf(stderr, "Should have not found anything.\n");
352 abort();
353 }
354
355 /* Test it by not finding it */
356 copy_to_msg(msg, paging_by_lac_cmd, sizeof(paging_by_lac_cmd));
357 parsed = bsc_nat_parse(msg);
358 if (bsc_nat_find_bsc(nat, msg) != 0) {
359 fprintf(stderr, "Should have not found aynthing.\n");
360 abort();
361 }
362 talloc_free(parsed);
363
364 /* Test by finding it */
Holger Hans Peter Freyther47dd4942010-04-06 15:11:34 +0200365 cfg.lac = 8213;
Holger Hans Peter Freyther04fd9922010-03-30 06:51:53 +0200366 copy_to_msg(msg, paging_by_lac_cmd, sizeof(paging_by_lac_cmd));
367 parsed = bsc_nat_parse(msg);
368 if (bsc_nat_find_bsc(nat, msg) != con) {
369 fprintf(stderr, "Should have found it.\n");
370 abort();
371 }
372 talloc_free(parsed);
373}
374
Holger Hans Peter Freytherfc9bd232010-04-01 03:55:27 +0200375static void test_mgcp_ass_tracking(void)
Holger Hans Peter Freyther465313e2010-06-15 18:49:53 +0800376{
377 struct sccp_connections con;
378 struct bsc_nat_parsed *parsed;
379 struct msgb *msg;
380
381 fprintf(stderr, "Testing MGCP.\n");
382 memset(&con, 0, sizeof(con));
383
384 msg = msgb_alloc(4096, "foo");
385 copy_to_msg(msg, ass_cmd, sizeof(ass_cmd));
386 parsed = bsc_nat_parse(msg);
387 if (bsc_mgcp_assign(&con, msg) != 0) {
388 fprintf(stderr, "Failed to handle assignment.\n");
389 abort();
390 }
391
392 if (con.msc_timeslot != 21) {
393 fprintf(stderr, "Timeslot should be 21.\n");
394 abort();
395 }
396
397 if (con.bsc_timeslot != 21) {
398 fprintf(stderr, "Assigned timeslot should have been 21.\n");
399 abort();
400 }
401 talloc_free(parsed);
402
403 bsc_mgcp_clear(&con);
404 if (con.bsc_timeslot != -1 || con.msc_timeslot != -1) {
405 fprintf(stderr, "Clearing should remove the mapping.\n");
406 abort();
407 }
408}
409
Holger Hans Peter Freytherfc9bd232010-04-01 03:55:27 +0200410/* test the code to find a given connection */
411static void test_mgcp_find(void)
412{
413 struct bsc_nat *nat;
414 struct bsc_connection *con;
415 struct sccp_connections *sccp_con;
416
417 fprintf(stderr, "Testing finding of a BSC Connection\n");
418
419 nat = bsc_nat_alloc();
420 con = bsc_connection_alloc(nat);
421 llist_add(&con->list_entry, &nat->bsc_connections);
422
423 sccp_con = talloc_zero(con, struct sccp_connections);
424 sccp_con->msc_timeslot = 12;
425 sccp_con->bsc_timeslot = 12;
426 sccp_con->bsc = con;
427 llist_add(&sccp_con->list_entry, &nat->sccp_connections);
428
429 if (bsc_mgcp_find_con(nat, 11) != NULL) {
430 fprintf(stderr, "Found the wrong connection.\n");
431 abort();
432 }
433
434 if (bsc_mgcp_find_con(nat, 12) != con) {
435 fprintf(stderr, "Didn't find the connection\n");
436 abort();
437 }
438
439 sccp_con->msc_timeslot = 0;
440 sccp_con->bsc_timeslot = 0;
441 if (bsc_mgcp_find_con(nat, 1) != con) {
442 fprintf(stderr, "Didn't find the connection\n");
443 abort();
444 }
445
446 /* free everything */
447 talloc_free(nat);
448}
449
Holger Hans Peter Freyther76c83542010-04-01 06:48:52 +0200450static void test_mgcp_rewrite(void)
451{
452 int i;
Holger Hans Peter Freyther8d200652010-04-04 18:09:10 +0200453 struct msgb *output;
Holger Hans Peter Freyther76c83542010-04-01 06:48:52 +0200454 fprintf(stderr, "Test rewriting MGCP messages.\n");
455
Holger Hans Peter Freyther76c83542010-04-01 06:48:52 +0200456 for (i = 0; i < ARRAY_SIZE(mgcp_messages); ++i) {
457 const char *orig = mgcp_messages[i].orig;
458 const char *patc = mgcp_messages[i].patch;
459 const char *ip = mgcp_messages[i].ip;
460 const int port = mgcp_messages[i].port;
461
Holger Hans Peter Freyther8d200652010-04-04 18:09:10 +0200462 char *input = strdup(orig);
Holger Hans Peter Freyther76c83542010-04-01 06:48:52 +0200463
Holger Hans Peter Freyther8d200652010-04-04 18:09:10 +0200464 output = bsc_mgcp_rewrite(input, strlen(input), ip, port);
Holger Hans Peter Freyther76c83542010-04-01 06:48:52 +0200465 if (msgb_l2len(output) != strlen(patc)) {
466 fprintf(stderr, "Wrong sizes for test: %d %d != %d != %d\n", i, msgb_l2len(output), strlen(patc), strlen(orig));
467 fprintf(stderr, "String '%s' vs '%s'\n", (const char *) output->l2h, patc);
468 abort();
469 }
470
471 if (memcmp(output->l2h, patc, msgb_l2len(output)) != 0) {
472 fprintf(stderr, "Broken on %d msg: '%s'\n", i, (const char *) output->l2h);
473 abort();
474 }
475
476 msgb_free(output);
Holger Hans Peter Freyther8d200652010-04-04 18:09:10 +0200477 free(input);
Holger Hans Peter Freyther76c83542010-04-01 06:48:52 +0200478 }
Holger Hans Peter Freyther76c83542010-04-01 06:48:52 +0200479}
480
Holger Hans Peter Freyther3c3bce12010-04-01 10:16:28 +0200481static void test_mgcp_parse(void)
482{
483 int code, ci;
484 char transaction[60];
485
486 fprintf(stderr, "Test MGCP response parsing.\n");
487
488 if (bsc_mgcp_parse_response(crcx_resp, &code, transaction) != 0) {
489 fprintf(stderr, "Failed to parse CRCX resp.\n");
490 abort();
491 }
492
493 if (code != 200) {
494 fprintf(stderr, "Failed to parse the CODE properly. Got: %d\n", code);
495 abort();
496 }
497
498 if (strcmp(transaction, "23265295") != 0) {
499 fprintf(stderr, "Failed to parse transaction id: '%s'\n", transaction);
500 abort();
501 }
502
503 ci = bsc_mgcp_extract_ci(crcx_resp);
504 if (ci != 1) {
505 fprintf(stderr, "Failed to parse the CI. Got: %d\n", ci);
506 abort();
507 }
508}
509
Holger Hans Peter Freyther38f7c752010-06-15 18:48:36 +0800510int main(int argc, char **argv)
511{
512 struct debug_target *stderr_target;
513
514 stderr_target = debug_target_create_stderr();
515 debug_add_target(stderr_target);
516 debug_set_all_filter(stderr_target, 1);
517
518 test_filter();
Holger Hans Peter Freyther04fd9922010-03-30 06:51:53 +0200519 test_contrack();
Holger Hans Peter Freyther04fd9922010-03-30 06:51:53 +0200520 test_paging();
Holger Hans Peter Freytherfc9bd232010-04-01 03:55:27 +0200521 test_mgcp_ass_tracking();
522 test_mgcp_find();
Holger Hans Peter Freyther76c83542010-04-01 06:48:52 +0200523 test_mgcp_rewrite();
Holger Hans Peter Freyther3c3bce12010-04-01 10:16:28 +0200524 test_mgcp_parse();
Holger Hans Peter Freyther0b8f69d2010-06-15 18:45:38 +0800525 return 0;
526}
Holger Hans Peter Freyther38f7c752010-06-15 18:48:36 +0800527
528void input_event()
529{}
530int nm_state_event()
531{
532 return -1;
533}
534
535int gsm0408_rcvmsg(struct msgb *msg, u_int8_t link_id)
536{
537 return -1;
538}