Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 1 | /* |
| 2 | * BSC NAT Message filtering |
| 3 | * |
| 4 | * (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org> |
Holger Hans Peter Freyther | 98e49d4 | 2010-06-15 18:46:56 +0800 | [diff] [blame] | 5 | * (C) 2010 by On-Waves |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 6 | * |
| 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> |
Holger Hans Peter Freyther | 4a9dd3b | 2010-07-31 05:17:17 +0800 | [diff] [blame] | 29 | #include <openbsc/bsc_nat_sccp.h> |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 30 | |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 31 | #include <osmocore/talloc.h> |
| 32 | |
Harald Welte | 90e5eae | 2010-08-03 15:11:51 +0200 | [diff] [blame] | 33 | #include <osmocom/sccp/sccp.h> |
Holger Hans Peter Freyther | a15e257 | 2010-09-15 05:20:40 +0800 | [diff] [blame] | 34 | #include <osmocore/protocol/gsm_08_08.h> |
Holger Hans Peter Freyther | a8dffc1 | 2010-07-30 02:53:14 +0800 | [diff] [blame] | 35 | |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 36 | #include <stdio.h> |
| 37 | |
| 38 | /* test messages for ipa */ |
Holger Hans Peter Freyther | 0b77635 | 2010-07-23 19:08:55 +0800 | [diff] [blame] | 39 | static uint8_t ipa_id[] = { |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 40 | 0x00, 0x01, 0xfe, 0x06, |
| 41 | }; |
| 42 | |
| 43 | /* SCCP messages are below */ |
Holger Hans Peter Freyther | 0b77635 | 2010-07-23 19:08:55 +0800 | [diff] [blame] | 44 | static uint8_t gsm_reset[] = { |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 45 | 0x00, 0x12, 0xfd, |
| 46 | 0x09, 0x00, 0x03, 0x05, 0x07, 0x02, 0x42, 0xfe, |
| 47 | 0x02, 0x42, 0xfe, 0x06, 0x00, 0x04, 0x30, 0x04, |
| 48 | 0x01, 0x20, |
| 49 | }; |
| 50 | |
Holger Hans Peter Freyther | 0b77635 | 2010-07-23 19:08:55 +0800 | [diff] [blame] | 51 | static const uint8_t gsm_reset_ack[] = { |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 52 | 0x00, 0x13, 0xfd, |
| 53 | 0x09, 0x00, 0x03, 0x07, 0x0b, 0x04, 0x43, 0x01, |
| 54 | 0x00, 0xfe, 0x04, 0x43, 0x5c, 0x00, 0xfe, 0x03, |
| 55 | 0x00, 0x01, 0x31, |
| 56 | }; |
| 57 | |
Holger Hans Peter Freyther | 0b77635 | 2010-07-23 19:08:55 +0800 | [diff] [blame] | 58 | static const uint8_t gsm_paging[] = { |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 59 | 0x00, 0x20, 0xfd, |
| 60 | 0x09, 0x00, 0x03, 0x07, 0x0b, 0x04, 0x43, 0x01, |
| 61 | 0x00, 0xfe, 0x04, 0x43, 0x5c, 0x00, 0xfe, 0x10, |
| 62 | 0x00, 0x0e, 0x52, 0x08, 0x08, 0x29, 0x47, 0x10, |
| 63 | 0x02, 0x01, 0x31, 0x97, 0x61, 0x1a, 0x01, 0x06, |
| 64 | }; |
| 65 | |
| 66 | /* BSC -> MSC connection open */ |
Holger Hans Peter Freyther | 0b77635 | 2010-07-23 19:08:55 +0800 | [diff] [blame] | 67 | static const uint8_t bssmap_cr[] = { |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 68 | 0x00, 0x2c, 0xfd, |
| 69 | 0x01, 0x01, 0x02, 0x03, 0x02, 0x02, 0x04, 0x02, |
| 70 | 0x42, 0xfe, 0x0f, 0x1f, 0x00, 0x1d, 0x57, 0x05, |
| 71 | 0x08, 0x00, 0x72, 0xf4, 0x80, 0x20, 0x12, 0xc3, |
| 72 | 0x50, 0x17, 0x10, 0x05, 0x24, 0x11, 0x03, 0x33, |
| 73 | 0x19, 0xa2, 0x08, 0x29, 0x47, 0x10, 0x02, 0x01, |
| 74 | 0x31, 0x97, 0x61, 0x00 |
| 75 | }; |
| 76 | |
| 77 | /* MSC -> BSC connection confirm */ |
Holger Hans Peter Freyther | 0b77635 | 2010-07-23 19:08:55 +0800 | [diff] [blame] | 78 | static const uint8_t bssmap_cc[] = { |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 79 | 0x00, 0x0a, 0xfd, |
| 80 | 0x02, 0x01, 0x02, 0x03, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, |
| 81 | }; |
| 82 | |
| 83 | /* MSC -> BSC released */ |
Holger Hans Peter Freyther | 0b77635 | 2010-07-23 19:08:55 +0800 | [diff] [blame] | 84 | static const uint8_t bssmap_released[] = { |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 85 | 0x00, 0x0e, 0xfd, |
| 86 | 0x04, 0x00, 0x00, 0x03, 0x01, 0x02, 0x03, 0x00, 0x01, 0x0f, |
| 87 | 0x02, 0x23, 0x42, 0x00, |
| 88 | }; |
| 89 | |
| 90 | /* BSC -> MSC released */ |
Holger Hans Peter Freyther | 0b77635 | 2010-07-23 19:08:55 +0800 | [diff] [blame] | 91 | static const uint8_t bssmap_release_complete[] = { |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 92 | 0x00, 0x07, 0xfd, |
| 93 | 0x05, 0x01, 0x02, 0x03, 0x00, 0x00, 0x03 |
| 94 | }; |
| 95 | |
Holger Hans Peter Freyther | 55e8f55 | 2010-04-06 10:22:01 +0200 | [diff] [blame] | 96 | /* both directions IT timer */ |
Holger Hans Peter Freyther | 0b77635 | 2010-07-23 19:08:55 +0800 | [diff] [blame] | 97 | static const uint8_t connnection_it[] = { |
Holger Hans Peter Freyther | 55e8f55 | 2010-04-06 10:22:01 +0200 | [diff] [blame] | 98 | 0x00, 0x0b, 0xfd, |
| 99 | 0x10, 0x01, 0x02, 0x03, 0x01, 0x02, 0x03, |
| 100 | 0x00, 0x00, 0x00, 0x00, |
| 101 | }; |
| 102 | |
Holger Hans Peter Freyther | dd6c51b | 2010-04-21 15:45:26 +0800 | [diff] [blame] | 103 | /* error in both directions */ |
Holger Hans Peter Freyther | 0b77635 | 2010-07-23 19:08:55 +0800 | [diff] [blame] | 104 | static const uint8_t proto_error[] = { |
Holger Hans Peter Freyther | dd6c51b | 2010-04-21 15:45:26 +0800 | [diff] [blame] | 105 | 0x00, 0x05, 0xfd, |
| 106 | 0x0f, 0x22, 0x33, 0x44, 0x00, |
| 107 | }; |
| 108 | |
Holger Hans Peter Freyther | 6b99828 | 2010-04-01 08:47:12 +0200 | [diff] [blame] | 109 | /* MGCP wrap... */ |
Holger Hans Peter Freyther | 0b77635 | 2010-07-23 19:08:55 +0800 | [diff] [blame] | 110 | static const uint8_t mgcp_msg[] = { |
Holger Hans Peter Freyther | 6b99828 | 2010-04-01 08:47:12 +0200 | [diff] [blame] | 111 | 0x00, 0x03, 0xfc, |
| 112 | 0x20, 0x20, 0x20, |
| 113 | }; |
| 114 | |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 115 | /* location updating request */ |
Holger Hans Peter Freyther | 0b77635 | 2010-07-23 19:08:55 +0800 | [diff] [blame] | 116 | static const uint8_t bss_lu[] = { |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 117 | 0x00, 0x2e, 0xfd, |
| 118 | 0x01, 0x91, 0x45, 0x14, 0x02, 0x02, 0x04, 0x02, |
| 119 | 0x42, 0xfe, 0x0f, 0x21, 0x00, 0x1f, 0x57, 0x05, |
| 120 | 0x08, 0x00, 0x72, 0xf4, 0x80, 0x20, 0x14, 0xc3, |
| 121 | 0x50, 0x17, 0x12, 0x05, 0x08, 0x70, 0x72, 0xf4, |
| 122 | 0x80, 0xff, 0xfe, 0x30, 0x08, 0x29, 0x44, 0x50, |
| 123 | 0x12, 0x03, 0x24, 0x01, 0x95, 0x00 |
| 124 | }; |
| 125 | |
Holger Hans Peter Freyther | ecaa0b1 | 2010-05-15 23:54:04 +0800 | [diff] [blame] | 126 | /* paging response */ |
| 127 | static const uint8_t pag_resp[] = { |
| 128 | 0x00, 0x2c, 0xfd, 0x01, 0xe5, 0x68, |
| 129 | 0x14, 0x02, 0x02, 0x04, 0x02, 0x42, 0xfe, 0x0f, |
| 130 | 0x1f, 0x00, 0x1d, 0x57, 0x05, 0x08, 0x00, 0x72, |
| 131 | 0xf4, 0x80, 0x20, 0x16, 0xc3, 0x50, 0x17, 0x10, |
| 132 | 0x06, 0x27, 0x01, 0x03, 0x30, 0x18, 0x96, 0x08, |
| 133 | 0x29, 0x26, 0x30, 0x32, 0x11, 0x42, 0x01, 0x19, |
| 134 | 0x00 |
| 135 | }; |
| 136 | |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 137 | struct filter_result { |
Holger Hans Peter Freyther | 0b77635 | 2010-07-23 19:08:55 +0800 | [diff] [blame] | 138 | const uint8_t *data; |
Holger Hans Peter Freyther | bd11639 | 2010-07-23 19:09:21 +0800 | [diff] [blame] | 139 | const uint16_t length; |
Holger Hans Peter Freyther | bbf6b65 | 2010-01-30 11:53:30 +0100 | [diff] [blame] | 140 | const int dir; |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 141 | const int result; |
| 142 | }; |
| 143 | |
| 144 | static const struct filter_result results[] = { |
| 145 | { |
| 146 | .data = ipa_id, |
| 147 | .length = ARRAY_SIZE(ipa_id), |
Holger Hans Peter Freyther | bbf6b65 | 2010-01-30 11:53:30 +0100 | [diff] [blame] | 148 | .dir = DIR_MSC, |
| 149 | .result = 1, |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 150 | }, |
| 151 | { |
| 152 | .data = gsm_reset, |
| 153 | .length = ARRAY_SIZE(gsm_reset), |
Holger Hans Peter Freyther | bbf6b65 | 2010-01-30 11:53:30 +0100 | [diff] [blame] | 154 | .dir = DIR_MSC, |
| 155 | .result = 1, |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 156 | }, |
| 157 | { |
| 158 | .data = gsm_reset_ack, |
| 159 | .length = ARRAY_SIZE(gsm_reset_ack), |
Holger Hans Peter Freyther | bbf6b65 | 2010-01-30 11:53:30 +0100 | [diff] [blame] | 160 | .dir = DIR_BSC, |
| 161 | .result = 1, |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 162 | }, |
| 163 | { |
| 164 | .data = gsm_paging, |
| 165 | .length = ARRAY_SIZE(gsm_paging), |
Holger Hans Peter Freyther | bbf6b65 | 2010-01-30 11:53:30 +0100 | [diff] [blame] | 166 | .dir = DIR_BSC, |
| 167 | .result = 0, |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 168 | }, |
| 169 | { |
| 170 | .data = bssmap_cr, |
| 171 | .length = ARRAY_SIZE(bssmap_cr), |
Holger Hans Peter Freyther | bbf6b65 | 2010-01-30 11:53:30 +0100 | [diff] [blame] | 172 | .dir = DIR_MSC, |
| 173 | .result = 0, |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 174 | }, |
| 175 | { |
| 176 | .data = bssmap_cc, |
| 177 | .length = ARRAY_SIZE(bssmap_cc), |
Holger Hans Peter Freyther | bbf6b65 | 2010-01-30 11:53:30 +0100 | [diff] [blame] | 178 | .dir = DIR_BSC, |
| 179 | .result = 0, |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 180 | }, |
| 181 | { |
| 182 | .data = bssmap_released, |
| 183 | .length = ARRAY_SIZE(bssmap_released), |
Holger Hans Peter Freyther | bbf6b65 | 2010-01-30 11:53:30 +0100 | [diff] [blame] | 184 | .dir = DIR_MSC, |
| 185 | .result = 0, |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 186 | }, |
| 187 | { |
| 188 | .data = bssmap_release_complete, |
| 189 | .length = ARRAY_SIZE(bssmap_release_complete), |
Holger Hans Peter Freyther | bbf6b65 | 2010-01-30 11:53:30 +0100 | [diff] [blame] | 190 | .dir = DIR_BSC, |
| 191 | .result = 0, |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 192 | }, |
Holger Hans Peter Freyther | 6b99828 | 2010-04-01 08:47:12 +0200 | [diff] [blame] | 193 | { |
| 194 | .data = mgcp_msg, |
| 195 | .length = ARRAY_SIZE(mgcp_msg), |
| 196 | .dir = DIR_MSC, |
| 197 | .result = 0, |
| 198 | }, |
Holger Hans Peter Freyther | 55e8f55 | 2010-04-06 10:22:01 +0200 | [diff] [blame] | 199 | { |
| 200 | .data = connnection_it, |
| 201 | .length = ARRAY_SIZE(connnection_it), |
| 202 | .dir = DIR_BSC, |
| 203 | .result = 0, |
| 204 | }, |
| 205 | { |
| 206 | .data = connnection_it, |
| 207 | .length = ARRAY_SIZE(connnection_it), |
| 208 | .dir = DIR_MSC, |
| 209 | .result = 0, |
| 210 | }, |
Holger Hans Peter Freyther | dd6c51b | 2010-04-21 15:45:26 +0800 | [diff] [blame] | 211 | { |
| 212 | .data = proto_error, |
| 213 | .length = ARRAY_SIZE(proto_error), |
| 214 | .dir = DIR_BSC, |
| 215 | .result = 0, |
| 216 | }, |
| 217 | { |
| 218 | .data = proto_error, |
| 219 | .length = ARRAY_SIZE(proto_error), |
| 220 | .dir = DIR_MSC, |
| 221 | .result = 0, |
| 222 | }, |
| 223 | |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 224 | }; |
| 225 | |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 226 | static void test_filter(void) |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 227 | { |
| 228 | int i; |
| 229 | |
| 230 | |
| 231 | /* start testinh with proper messages */ |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 232 | fprintf(stderr, "Testing BSS Filtering.\n"); |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 233 | for (i = 0; i < ARRAY_SIZE(results); ++i) { |
| 234 | int result; |
| 235 | struct bsc_nat_parsed *parsed; |
| 236 | struct msgb *msg = msgb_alloc(4096, "test-message"); |
| 237 | |
| 238 | fprintf(stderr, "Going to test item: %d\n", i); |
| 239 | memcpy(msg->data, results[i].data, results[i].length); |
| 240 | msg->l2h = msgb_put(msg, results[i].length); |
| 241 | |
| 242 | parsed = bsc_nat_parse(msg); |
| 243 | if (!parsed) { |
| 244 | fprintf(stderr, "FAIL: Failed to parse the message\n"); |
| 245 | continue; |
| 246 | } |
| 247 | |
Holger Hans Peter Freyther | bbf6b65 | 2010-01-30 11:53:30 +0100 | [diff] [blame] | 248 | result = bsc_nat_filter_ipa(results[i].dir, msg, parsed); |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 249 | if (result != results[i].result) { |
| 250 | fprintf(stderr, "FAIL: Not the expected result got: %d wanted: %d\n", |
| 251 | result, results[i].result); |
| 252 | } |
| 253 | |
| 254 | msgb_free(msg); |
| 255 | } |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 256 | } |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 257 | |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 258 | #include "bsc_data.c" |
| 259 | |
Holger Hans Peter Freyther | 0b77635 | 2010-07-23 19:08:55 +0800 | [diff] [blame] | 260 | static void copy_to_msg(struct msgb *msg, const uint8_t *data, unsigned int length) |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 261 | { |
| 262 | msgb_reset(msg); |
| 263 | msg->l2h = msgb_put(msg, length); |
| 264 | memcpy(msg->l2h, data, msgb_l2len(msg)); |
| 265 | } |
| 266 | |
| 267 | #define VERIFY(con_found, con, msg, ver, str) \ |
Holger Hans Peter Freyther | 75ee841 | 2010-06-15 18:48:55 +0800 | [diff] [blame] | 268 | if (!con_found || con_found->bsc != con) { \ |
Holger Hans Peter Freyther | d062c52 | 2010-06-15 18:48:44 +0800 | [diff] [blame] | 269 | fprintf(stderr, "Failed to find the con: %p\n", con_found); \ |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 270 | abort(); \ |
| 271 | } \ |
| 272 | if (memcmp(msg->data, ver, sizeof(ver)) != 0) { \ |
| 273 | fprintf(stderr, "Failed to patch the %s msg.\n", str); \ |
| 274 | abort(); \ |
| 275 | } |
| 276 | |
| 277 | /* test conn tracking once */ |
| 278 | static void test_contrack() |
| 279 | { |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 280 | struct bsc_nat *nat; |
Holger Hans Peter Freyther | 75ee841 | 2010-06-15 18:48:55 +0800 | [diff] [blame] | 281 | struct bsc_connection *con; |
| 282 | struct sccp_connections *con_found; |
Holger Hans Peter Freyther | e1a1648 | 2010-05-16 16:51:31 +0800 | [diff] [blame] | 283 | struct sccp_connections *rc_con; |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 284 | struct bsc_nat_parsed *parsed; |
| 285 | struct msgb *msg; |
| 286 | |
| 287 | fprintf(stderr, "Testing connection tracking.\n"); |
| 288 | nat = bsc_nat_alloc(); |
| 289 | con = bsc_connection_alloc(nat); |
Holger Hans Peter Freyther | 1f04083 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 290 | con->cfg = bsc_config_alloc(nat, "foo"); |
| 291 | bsc_config_add_lac(con->cfg, 23); |
| 292 | bsc_config_add_lac(con->cfg, 49); |
| 293 | bsc_config_add_lac(con->cfg, 42); |
| 294 | bsc_config_del_lac(con->cfg, 49); |
| 295 | bsc_config_add_lac(con->cfg, 1111); |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 296 | msg = msgb_alloc(4096, "test"); |
| 297 | |
| 298 | /* 1.) create a connection */ |
| 299 | copy_to_msg(msg, bsc_cr, sizeof(bsc_cr)); |
| 300 | parsed = bsc_nat_parse(msg); |
Holger Hans Peter Freyther | da30c4b | 2010-04-21 18:56:12 +0800 | [diff] [blame] | 301 | con_found = patch_sccp_src_ref_to_msc(msg, parsed, con); |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 302 | if (con_found != NULL) { |
Holger Hans Peter Freyther | d062c52 | 2010-06-15 18:48:44 +0800 | [diff] [blame] | 303 | fprintf(stderr, "Con should not exist %p\n", con_found); |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 304 | abort(); |
| 305 | } |
Holger Hans Peter Freyther | e1a1648 | 2010-05-16 16:51:31 +0800 | [diff] [blame] | 306 | rc_con = create_sccp_src_ref(con, parsed); |
| 307 | if (!rc_con) { |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 308 | fprintf(stderr, "Failed to create a ref\n"); |
| 309 | abort(); |
| 310 | } |
Holger Hans Peter Freyther | da30c4b | 2010-04-21 18:56:12 +0800 | [diff] [blame] | 311 | con_found = patch_sccp_src_ref_to_msc(msg, parsed, con); |
Holger Hans Peter Freyther | 75ee841 | 2010-06-15 18:48:55 +0800 | [diff] [blame] | 312 | if (!con_found || con_found->bsc != con) { |
Holger Hans Peter Freyther | d062c52 | 2010-06-15 18:48:44 +0800 | [diff] [blame] | 313 | fprintf(stderr, "Failed to find the con: %p\n", con_found); |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 314 | abort(); |
| 315 | } |
Holger Hans Peter Freyther | e1a1648 | 2010-05-16 16:51:31 +0800 | [diff] [blame] | 316 | if (con_found != rc_con) { |
| 317 | fprintf(stderr, "Failed to find the right connection.\n"); |
| 318 | abort(); |
| 319 | } |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 320 | if (memcmp(msg->data, bsc_cr_patched, sizeof(bsc_cr_patched)) != 0) { |
| 321 | fprintf(stderr, "Failed to patch the BSC CR msg.\n"); |
| 322 | abort(); |
| 323 | } |
| 324 | talloc_free(parsed); |
| 325 | |
| 326 | /* 2.) get the cc */ |
| 327 | copy_to_msg(msg, msc_cc, sizeof(msc_cc)); |
| 328 | parsed = bsc_nat_parse(msg); |
Holger Hans Peter Freyther | 75ee841 | 2010-06-15 18:48:55 +0800 | [diff] [blame] | 329 | con_found = patch_sccp_src_ref_to_bsc(msg, parsed, nat); |
| 330 | VERIFY(con_found, con, msg, msc_cc_patched, "MSC CC"); |
| 331 | if (update_sccp_src_ref(con_found, parsed) != 0) { |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 332 | fprintf(stderr, "Failed to update the SCCP con.\n"); |
| 333 | abort(); |
| 334 | } |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 335 | |
| 336 | /* 3.) send some data */ |
| 337 | copy_to_msg(msg, bsc_dtap, sizeof(bsc_dtap)); |
| 338 | parsed = bsc_nat_parse(msg); |
Holger Hans Peter Freyther | da30c4b | 2010-04-21 18:56:12 +0800 | [diff] [blame] | 339 | con_found = patch_sccp_src_ref_to_msc(msg, parsed, con); |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 340 | VERIFY(con_found, con, msg, bsc_dtap_patched, "BSC DTAP"); |
| 341 | |
| 342 | /* 4.) receive some data */ |
| 343 | copy_to_msg(msg, msc_dtap, sizeof(msc_dtap)); |
| 344 | parsed = bsc_nat_parse(msg); |
| 345 | con_found = patch_sccp_src_ref_to_bsc(msg, parsed, nat); |
| 346 | VERIFY(con_found, con, msg, msc_dtap_patched, "MSC DTAP"); |
| 347 | |
| 348 | /* 5.) close the connection */ |
| 349 | copy_to_msg(msg, msc_rlsd, sizeof(msc_rlsd)); |
| 350 | parsed = bsc_nat_parse(msg); |
| 351 | con_found = patch_sccp_src_ref_to_bsc(msg, parsed, nat); |
| 352 | VERIFY(con_found, con, msg, msc_rlsd_patched, "MSC RLSD"); |
| 353 | |
| 354 | /* 6.) confirm the connection close */ |
| 355 | copy_to_msg(msg, bsc_rlc, sizeof(bsc_rlc)); |
| 356 | parsed = bsc_nat_parse(msg); |
Holger Hans Peter Freyther | da30c4b | 2010-04-21 18:56:12 +0800 | [diff] [blame] | 357 | con_found = patch_sccp_src_ref_to_msc(msg, parsed, con); |
Holger Hans Peter Freyther | 75ee841 | 2010-06-15 18:48:55 +0800 | [diff] [blame] | 358 | if (!con_found || con_found->bsc != con) { |
Holger Hans Peter Freyther | d062c52 | 2010-06-15 18:48:44 +0800 | [diff] [blame] | 359 | fprintf(stderr, "Failed to find the con: %p\n", con_found); |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 360 | abort(); |
| 361 | } |
| 362 | if (memcmp(msg->data, bsc_rlc_patched, sizeof(bsc_rlc_patched)) != 0) { |
| 363 | fprintf(stderr, "Failed to patch the BSC CR msg.\n"); |
| 364 | abort(); |
| 365 | } |
| 366 | remove_sccp_src_ref(con, msg, parsed); |
Holger Hans Peter Freyther | bedecf3 | 2010-04-05 21:44:51 +0200 | [diff] [blame] | 367 | talloc_free(parsed); |
| 368 | |
| 369 | copy_to_msg(msg, bsc_rlc, sizeof(bsc_rlc)); |
| 370 | parsed = bsc_nat_parse(msg); |
Holger Hans Peter Freyther | da30c4b | 2010-04-21 18:56:12 +0800 | [diff] [blame] | 371 | con_found = patch_sccp_src_ref_to_msc(msg, parsed, con); |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 372 | |
| 373 | /* verify that it is gone */ |
| 374 | if (con_found != NULL) { |
Holger Hans Peter Freyther | d062c52 | 2010-06-15 18:48:44 +0800 | [diff] [blame] | 375 | fprintf(stderr, "Con should be gone. %p\n", con_found); |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 376 | abort(); |
| 377 | } |
| 378 | talloc_free(parsed); |
| 379 | |
| 380 | |
| 381 | talloc_free(nat); |
| 382 | msgb_free(msg); |
| 383 | } |
| 384 | |
Holger Hans Peter Freyther | d5deb33 | 2010-03-30 06:51:53 +0200 | [diff] [blame] | 385 | static void test_paging(void) |
| 386 | { |
Holger Hans Peter Freyther | 935b2df | 2010-04-17 08:07:19 +0200 | [diff] [blame] | 387 | int lac; |
Holger Hans Peter Freyther | d5deb33 | 2010-03-30 06:51:53 +0200 | [diff] [blame] | 388 | struct bsc_nat *nat; |
| 389 | struct bsc_connection *con; |
| 390 | struct bsc_nat_parsed *parsed; |
Holger Hans Peter Freyther | 1f04083 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 391 | struct bsc_config *cfg; |
Holger Hans Peter Freyther | d5deb33 | 2010-03-30 06:51:53 +0200 | [diff] [blame] | 392 | struct msgb *msg; |
| 393 | |
| 394 | fprintf(stderr, "Testing paging by lac.\n"); |
| 395 | |
| 396 | nat = bsc_nat_alloc(); |
| 397 | con = bsc_connection_alloc(nat); |
Holger Hans Peter Freyther | 1f04083 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 398 | cfg = bsc_config_alloc(nat, "unknown"); |
| 399 | con->cfg = cfg; |
| 400 | bsc_config_add_lac(cfg, 23); |
Holger Hans Peter Freyther | d5deb33 | 2010-03-30 06:51:53 +0200 | [diff] [blame] | 401 | con->authenticated = 1; |
| 402 | llist_add(&con->list_entry, &nat->bsc_connections); |
| 403 | msg = msgb_alloc(4096, "test"); |
| 404 | |
| 405 | /* Test completely bad input */ |
| 406 | copy_to_msg(msg, paging_by_lac_cmd, sizeof(paging_by_lac_cmd)); |
Holger Hans Peter Freyther | 935b2df | 2010-04-17 08:07:19 +0200 | [diff] [blame] | 407 | if (bsc_nat_find_bsc(nat, msg, &lac) != 0) { |
Holger Hans Peter Freyther | d5deb33 | 2010-03-30 06:51:53 +0200 | [diff] [blame] | 408 | fprintf(stderr, "Should have not found anything.\n"); |
| 409 | abort(); |
| 410 | } |
| 411 | |
| 412 | /* Test it by not finding it */ |
| 413 | copy_to_msg(msg, paging_by_lac_cmd, sizeof(paging_by_lac_cmd)); |
| 414 | parsed = bsc_nat_parse(msg); |
Holger Hans Peter Freyther | 935b2df | 2010-04-17 08:07:19 +0200 | [diff] [blame] | 415 | if (bsc_nat_find_bsc(nat, msg, &lac) != 0) { |
Holger Hans Peter Freyther | d5deb33 | 2010-03-30 06:51:53 +0200 | [diff] [blame] | 416 | fprintf(stderr, "Should have not found aynthing.\n"); |
| 417 | abort(); |
| 418 | } |
| 419 | talloc_free(parsed); |
| 420 | |
| 421 | /* Test by finding it */ |
Holger Hans Peter Freyther | 1f04083 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 422 | bsc_config_del_lac(cfg, 23); |
| 423 | bsc_config_add_lac(cfg, 8213); |
Holger Hans Peter Freyther | d5deb33 | 2010-03-30 06:51:53 +0200 | [diff] [blame] | 424 | copy_to_msg(msg, paging_by_lac_cmd, sizeof(paging_by_lac_cmd)); |
| 425 | parsed = bsc_nat_parse(msg); |
Holger Hans Peter Freyther | 935b2df | 2010-04-17 08:07:19 +0200 | [diff] [blame] | 426 | if (bsc_nat_find_bsc(nat, msg, &lac) != con) { |
Holger Hans Peter Freyther | d5deb33 | 2010-03-30 06:51:53 +0200 | [diff] [blame] | 427 | fprintf(stderr, "Should have found it.\n"); |
| 428 | abort(); |
| 429 | } |
| 430 | talloc_free(parsed); |
| 431 | } |
| 432 | |
Holger Hans Peter Freyther | 8917998 | 2010-04-01 03:55:27 +0200 | [diff] [blame] | 433 | static void test_mgcp_ass_tracking(void) |
Holger Hans Peter Freyther | dccb915 | 2010-06-15 18:49:53 +0800 | [diff] [blame] | 434 | { |
Holger Hans Peter Freyther | 3633095 | 2010-04-22 12:08:17 +0800 | [diff] [blame] | 435 | struct bsc_connection *bsc; |
| 436 | struct bsc_nat *nat; |
Holger Hans Peter Freyther | dccb915 | 2010-06-15 18:49:53 +0800 | [diff] [blame] | 437 | struct sccp_connections con; |
| 438 | struct bsc_nat_parsed *parsed; |
| 439 | struct msgb *msg; |
| 440 | |
| 441 | fprintf(stderr, "Testing MGCP.\n"); |
| 442 | memset(&con, 0, sizeof(con)); |
| 443 | |
Holger Hans Peter Freyther | 3633095 | 2010-04-22 12:08:17 +0800 | [diff] [blame] | 444 | nat = bsc_nat_alloc(); |
| 445 | nat->bsc_endpoints = talloc_zero_array(nat, |
| 446 | struct bsc_endpoint, |
| 447 | 33); |
| 448 | bsc = bsc_connection_alloc(nat); |
Holger Hans Peter Freyther | 1f04083 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 449 | bsc->cfg = bsc_config_alloc(nat, "foo"); |
| 450 | bsc_config_add_lac(bsc->cfg, 2323); |
Holger Hans Peter Freyther | e62b766 | 2010-09-19 20:54:21 +0800 | [diff] [blame] | 451 | bsc->last_endpoint = 0x1a; |
Holger Hans Peter Freyther | 3633095 | 2010-04-22 12:08:17 +0800 | [diff] [blame] | 452 | con.bsc = bsc; |
| 453 | |
Holger Hans Peter Freyther | dccb915 | 2010-06-15 18:49:53 +0800 | [diff] [blame] | 454 | msg = msgb_alloc(4096, "foo"); |
| 455 | copy_to_msg(msg, ass_cmd, sizeof(ass_cmd)); |
| 456 | parsed = bsc_nat_parse(msg); |
Holger Hans Peter Freyther | 4bcb770 | 2010-09-20 01:21:51 +0800 | [diff] [blame] | 457 | |
| 458 | if (msg->l2h[16] != 0 || |
| 459 | msg->l2h[17] != 0x1) { |
| 460 | fprintf(stderr, "Input is not as expected.. %s 0x%x\n", |
| 461 | hexdump(msg->l2h, msgb_l2len(msg)), |
| 462 | msg->l2h[17]); |
| 463 | abort(); |
| 464 | } |
| 465 | |
Holger Hans Peter Freyther | 926c5fd | 2010-08-28 18:22:14 +0800 | [diff] [blame] | 466 | if (bsc_mgcp_assign_patch(&con, msg) != 0) { |
Holger Hans Peter Freyther | dccb915 | 2010-06-15 18:49:53 +0800 | [diff] [blame] | 467 | fprintf(stderr, "Failed to handle assignment.\n"); |
| 468 | abort(); |
| 469 | } |
| 470 | |
Holger Hans Peter Freyther | 4bcb770 | 2010-09-20 01:21:51 +0800 | [diff] [blame] | 471 | if (con.msc_endp != 1) { |
| 472 | fprintf(stderr, "Timeslot should be 1.\n"); |
Holger Hans Peter Freyther | dccb915 | 2010-06-15 18:49:53 +0800 | [diff] [blame] | 473 | abort(); |
| 474 | } |
| 475 | |
Holger Hans Peter Freyther | e62b766 | 2010-09-19 20:54:21 +0800 | [diff] [blame] | 476 | if (con.bsc_endp != 0x1b) { |
Holger Hans Peter Freyther | 926c5fd | 2010-08-28 18:22:14 +0800 | [diff] [blame] | 477 | fprintf(stderr, "Assigned timeslot should have been 1.\n"); |
Holger Hans Peter Freyther | dccb915 | 2010-06-15 18:49:53 +0800 | [diff] [blame] | 478 | abort(); |
| 479 | } |
Holger Hans Peter Freyther | e62b766 | 2010-09-19 20:54:21 +0800 | [diff] [blame] | 480 | if (con.bsc->endpoint_status[0x1b] != 1) { |
Holger Hans Peter Freyther | 926c5fd | 2010-08-28 18:22:14 +0800 | [diff] [blame] | 481 | fprintf(stderr, "The status on the BSC is wrong.\n"); |
| 482 | abort(); |
| 483 | } |
| 484 | |
Holger Hans Peter Freyther | 4bcb770 | 2010-09-20 01:21:51 +0800 | [diff] [blame] | 485 | int multiplex, timeslot; |
| 486 | mgcp_endpoint_to_timeslot(0x1b, &multiplex, ×lot); |
| 487 | |
| 488 | uint16_t cic = htons(timeslot & 0x1f); |
| 489 | if (memcmp(&cic, &msg->l2h[16], sizeof(cic)) != 0) { |
| 490 | fprintf(stderr, "Message was not patched properly\n"); |
| 491 | fprintf(stderr, "data cic: 0x%x %s\n", cic, hexdump(msg->l2h, msgb_l2len(msg))); |
| 492 | abort(); |
| 493 | } |
| 494 | |
Holger Hans Peter Freyther | dccb915 | 2010-06-15 18:49:53 +0800 | [diff] [blame] | 495 | talloc_free(parsed); |
| 496 | |
Holger Hans Peter Freyther | 3633095 | 2010-04-22 12:08:17 +0800 | [diff] [blame] | 497 | bsc_mgcp_dlcx(&con); |
Holger Hans Peter Freyther | e62b766 | 2010-09-19 20:54:21 +0800 | [diff] [blame] | 498 | if (con.bsc_endp != -1 || con.msc_endp != -1 || |
| 499 | con.bsc->endpoint_status[1] != 0 || con.bsc->last_endpoint != 0x1b) { |
Holger Hans Peter Freyther | dccb915 | 2010-06-15 18:49:53 +0800 | [diff] [blame] | 500 | fprintf(stderr, "Clearing should remove the mapping.\n"); |
| 501 | abort(); |
| 502 | } |
Holger Hans Peter Freyther | 3633095 | 2010-04-22 12:08:17 +0800 | [diff] [blame] | 503 | |
| 504 | talloc_free(nat); |
Holger Hans Peter Freyther | dccb915 | 2010-06-15 18:49:53 +0800 | [diff] [blame] | 505 | } |
| 506 | |
Holger Hans Peter Freyther | 8917998 | 2010-04-01 03:55:27 +0200 | [diff] [blame] | 507 | /* test the code to find a given connection */ |
| 508 | static void test_mgcp_find(void) |
| 509 | { |
| 510 | struct bsc_nat *nat; |
| 511 | struct bsc_connection *con; |
| 512 | struct sccp_connections *sccp_con; |
| 513 | |
| 514 | fprintf(stderr, "Testing finding of a BSC Connection\n"); |
| 515 | |
| 516 | nat = bsc_nat_alloc(); |
| 517 | con = bsc_connection_alloc(nat); |
| 518 | llist_add(&con->list_entry, &nat->bsc_connections); |
| 519 | |
| 520 | sccp_con = talloc_zero(con, struct sccp_connections); |
Holger Hans Peter Freyther | 7089d53 | 2010-08-28 16:08:39 +0800 | [diff] [blame] | 521 | sccp_con->msc_endp = 12; |
| 522 | sccp_con->bsc_endp = 12; |
Holger Hans Peter Freyther | 8917998 | 2010-04-01 03:55:27 +0200 | [diff] [blame] | 523 | sccp_con->bsc = con; |
| 524 | llist_add(&sccp_con->list_entry, &nat->sccp_connections); |
| 525 | |
| 526 | if (bsc_mgcp_find_con(nat, 11) != NULL) { |
| 527 | fprintf(stderr, "Found the wrong connection.\n"); |
| 528 | abort(); |
| 529 | } |
| 530 | |
Holger Hans Peter Freyther | 98d15ef | 2010-04-18 02:26:16 +0800 | [diff] [blame] | 531 | if (bsc_mgcp_find_con(nat, 12) != sccp_con) { |
Holger Hans Peter Freyther | 8917998 | 2010-04-01 03:55:27 +0200 | [diff] [blame] | 532 | fprintf(stderr, "Didn't find the connection\n"); |
| 533 | abort(); |
| 534 | } |
| 535 | |
Holger Hans Peter Freyther | 8917998 | 2010-04-01 03:55:27 +0200 | [diff] [blame] | 536 | /* free everything */ |
| 537 | talloc_free(nat); |
| 538 | } |
| 539 | |
Holger Hans Peter Freyther | acd6420 | 2010-04-01 06:48:52 +0200 | [diff] [blame] | 540 | static void test_mgcp_rewrite(void) |
| 541 | { |
| 542 | int i; |
Holger Hans Peter Freyther | 0d0aaa6 | 2010-04-04 18:09:10 +0200 | [diff] [blame] | 543 | struct msgb *output; |
Holger Hans Peter Freyther | acd6420 | 2010-04-01 06:48:52 +0200 | [diff] [blame] | 544 | fprintf(stderr, "Test rewriting MGCP messages.\n"); |
| 545 | |
Holger Hans Peter Freyther | acd6420 | 2010-04-01 06:48:52 +0200 | [diff] [blame] | 546 | for (i = 0; i < ARRAY_SIZE(mgcp_messages); ++i) { |
| 547 | const char *orig = mgcp_messages[i].orig; |
| 548 | const char *patc = mgcp_messages[i].patch; |
| 549 | const char *ip = mgcp_messages[i].ip; |
| 550 | const int port = mgcp_messages[i].port; |
| 551 | |
Holger Hans Peter Freyther | 0d0aaa6 | 2010-04-04 18:09:10 +0200 | [diff] [blame] | 552 | char *input = strdup(orig); |
Holger Hans Peter Freyther | acd6420 | 2010-04-01 06:48:52 +0200 | [diff] [blame] | 553 | |
Holger Hans Peter Freyther | 4e6129a | 2010-08-30 13:44:32 +0800 | [diff] [blame] | 554 | output = bsc_mgcp_rewrite(input, strlen(input), 0x1e, ip, port); |
Holger Hans Peter Freyther | acd6420 | 2010-04-01 06:48:52 +0200 | [diff] [blame] | 555 | if (msgb_l2len(output) != strlen(patc)) { |
| 556 | fprintf(stderr, "Wrong sizes for test: %d %d != %d != %d\n", i, msgb_l2len(output), strlen(patc), strlen(orig)); |
| 557 | fprintf(stderr, "String '%s' vs '%s'\n", (const char *) output->l2h, patc); |
| 558 | abort(); |
| 559 | } |
| 560 | |
| 561 | if (memcmp(output->l2h, patc, msgb_l2len(output)) != 0) { |
| 562 | fprintf(stderr, "Broken on %d msg: '%s'\n", i, (const char *) output->l2h); |
| 563 | abort(); |
| 564 | } |
| 565 | |
| 566 | msgb_free(output); |
Holger Hans Peter Freyther | 0d0aaa6 | 2010-04-04 18:09:10 +0200 | [diff] [blame] | 567 | free(input); |
Holger Hans Peter Freyther | acd6420 | 2010-04-01 06:48:52 +0200 | [diff] [blame] | 568 | } |
Holger Hans Peter Freyther | acd6420 | 2010-04-01 06:48:52 +0200 | [diff] [blame] | 569 | } |
| 570 | |
Holger Hans Peter Freyther | 9fec010 | 2010-04-01 10:16:28 +0200 | [diff] [blame] | 571 | static void test_mgcp_parse(void) |
| 572 | { |
| 573 | int code, ci; |
| 574 | char transaction[60]; |
| 575 | |
| 576 | fprintf(stderr, "Test MGCP response parsing.\n"); |
| 577 | |
| 578 | if (bsc_mgcp_parse_response(crcx_resp, &code, transaction) != 0) { |
| 579 | fprintf(stderr, "Failed to parse CRCX resp.\n"); |
| 580 | abort(); |
| 581 | } |
| 582 | |
| 583 | if (code != 200) { |
| 584 | fprintf(stderr, "Failed to parse the CODE properly. Got: %d\n", code); |
| 585 | abort(); |
| 586 | } |
| 587 | |
| 588 | if (strcmp(transaction, "23265295") != 0) { |
| 589 | fprintf(stderr, "Failed to parse transaction id: '%s'\n", transaction); |
| 590 | abort(); |
| 591 | } |
| 592 | |
| 593 | ci = bsc_mgcp_extract_ci(crcx_resp); |
| 594 | if (ci != 1) { |
| 595 | fprintf(stderr, "Failed to parse the CI. Got: %d\n", ci); |
| 596 | abort(); |
| 597 | } |
| 598 | } |
| 599 | |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 600 | struct cr_filter { |
Holger Hans Peter Freyther | 0b77635 | 2010-07-23 19:08:55 +0800 | [diff] [blame] | 601 | const uint8_t *data; |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 602 | int length; |
| 603 | int result; |
Holger Hans Peter Freyther | d5a2bc4 | 2010-05-16 02:00:40 +0800 | [diff] [blame] | 604 | int contype; |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 605 | |
| 606 | const char *bsc_imsi_allow; |
| 607 | const char *bsc_imsi_deny; |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 608 | const char *nat_imsi_deny; |
| 609 | }; |
| 610 | |
| 611 | static struct cr_filter cr_filter[] = { |
| 612 | { |
| 613 | .data = bssmap_cr, |
| 614 | .length = sizeof(bssmap_cr), |
Holger Hans Peter Freyther | f4cf1e8 | 2010-09-15 01:42:07 +0800 | [diff] [blame] | 615 | .result = 1, |
Holger Hans Peter Freyther | d5a2bc4 | 2010-05-16 02:00:40 +0800 | [diff] [blame] | 616 | .contype = NAT_CON_TYPE_CM_SERV_REQ, |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 617 | }, |
| 618 | { |
| 619 | .data = bss_lu, |
| 620 | .length = sizeof(bss_lu), |
Holger Hans Peter Freyther | f4cf1e8 | 2010-09-15 01:42:07 +0800 | [diff] [blame] | 621 | .result = 1, |
Holger Hans Peter Freyther | d5a2bc4 | 2010-05-16 02:00:40 +0800 | [diff] [blame] | 622 | .contype = NAT_CON_TYPE_LU, |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 623 | }, |
| 624 | { |
Holger Hans Peter Freyther | ecaa0b1 | 2010-05-15 23:54:04 +0800 | [diff] [blame] | 625 | .data = pag_resp, |
| 626 | .length = sizeof(pag_resp), |
Holger Hans Peter Freyther | f4cf1e8 | 2010-09-15 01:42:07 +0800 | [diff] [blame] | 627 | .result = 1, |
Holger Hans Peter Freyther | d5a2bc4 | 2010-05-16 02:00:40 +0800 | [diff] [blame] | 628 | .contype = NAT_CON_TYPE_PAG_RESP, |
Holger Hans Peter Freyther | ecaa0b1 | 2010-05-15 23:54:04 +0800 | [diff] [blame] | 629 | }, |
| 630 | { |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 631 | /* nat deny is before blank/null BSC */ |
| 632 | .data = bss_lu, |
| 633 | .length = sizeof(bss_lu), |
| 634 | .result = -3, |
| 635 | .nat_imsi_deny = "[0-9]*", |
Holger Hans Peter Freyther | d5a2bc4 | 2010-05-16 02:00:40 +0800 | [diff] [blame] | 636 | .contype = NAT_CON_TYPE_LU, |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 637 | }, |
| 638 | { |
Holger Hans Peter Freyther | 58bce3f | 2010-05-14 23:07:58 +0800 | [diff] [blame] | 639 | /* BSC allow is before NAT deny */ |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 640 | .data = bss_lu, |
| 641 | .length = sizeof(bss_lu), |
Holger Hans Peter Freyther | f4cf1e8 | 2010-09-15 01:42:07 +0800 | [diff] [blame] | 642 | .result = 1, |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 643 | .nat_imsi_deny = "[0-9]*", |
Holger Hans Peter Freyther | 58bce3f | 2010-05-14 23:07:58 +0800 | [diff] [blame] | 644 | .bsc_imsi_allow = "2440[0-9]*", |
Holger Hans Peter Freyther | d5a2bc4 | 2010-05-16 02:00:40 +0800 | [diff] [blame] | 645 | .contype = NAT_CON_TYPE_LU, |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 646 | }, |
| 647 | { |
| 648 | /* BSC allow is before NAT deny */ |
| 649 | .data = bss_lu, |
| 650 | .length = sizeof(bss_lu), |
Holger Hans Peter Freyther | f4cf1e8 | 2010-09-15 01:42:07 +0800 | [diff] [blame] | 651 | .result = 1, |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 652 | .bsc_imsi_allow = "[0-9]*", |
| 653 | .nat_imsi_deny = "[0-9]*", |
Holger Hans Peter Freyther | d5a2bc4 | 2010-05-16 02:00:40 +0800 | [diff] [blame] | 654 | .contype = NAT_CON_TYPE_LU, |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 655 | }, |
| 656 | { |
| 657 | /* filter as deny is first */ |
| 658 | .data = bss_lu, |
| 659 | .length = sizeof(bss_lu), |
Holger Hans Peter Freyther | 6b340cc | 2010-10-19 20:55:33 +0200 | [diff] [blame] | 660 | .result = 1, |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 661 | .bsc_imsi_deny = "[0-9]*", |
| 662 | .bsc_imsi_allow = "[0-9]*", |
| 663 | .nat_imsi_deny = "[0-9]*", |
Holger Hans Peter Freyther | d5a2bc4 | 2010-05-16 02:00:40 +0800 | [diff] [blame] | 664 | .contype = NAT_CON_TYPE_LU, |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 665 | }, |
Holger Hans Peter Freyther | 6b340cc | 2010-10-19 20:55:33 +0200 | [diff] [blame] | 666 | { |
| 667 | /* deny by nat rule */ |
| 668 | .data = bss_lu, |
| 669 | .length = sizeof(bss_lu), |
| 670 | .result = -3, |
| 671 | .bsc_imsi_deny = "000[0-9]*", |
| 672 | .nat_imsi_deny = "[0-9]*", |
| 673 | .contype = NAT_CON_TYPE_LU, |
| 674 | }, |
| 675 | { |
| 676 | /* deny by bsc rule */ |
| 677 | .data = bss_lu, |
| 678 | .length = sizeof(bss_lu), |
| 679 | .result = -2, |
| 680 | .bsc_imsi_deny = "[0-9]*", |
| 681 | .contype = NAT_CON_TYPE_LU, |
| 682 | }, |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 683 | |
| 684 | }; |
| 685 | |
Holger Hans Peter Freyther | 28b08d6 | 2010-05-14 08:12:57 +0800 | [diff] [blame] | 686 | static void test_cr_filter() |
| 687 | { |
Holger Hans Peter Freyther | d5a2bc4 | 2010-05-16 02:00:40 +0800 | [diff] [blame] | 688 | int i, res, contype; |
Holger Hans Peter Freyther | 28b08d6 | 2010-05-14 08:12:57 +0800 | [diff] [blame] | 689 | struct msgb *msg = msgb_alloc(4096, "test_cr_filter"); |
Holger Hans Peter Freyther | 28b08d6 | 2010-05-14 08:12:57 +0800 | [diff] [blame] | 690 | struct bsc_nat_parsed *parsed; |
Holger Hans Peter Freyther | b604471 | 2010-06-08 10:14:44 +0800 | [diff] [blame] | 691 | struct bsc_nat_acc_lst *nat_lst, *bsc_lst; |
Holger Hans Peter Freyther | 8eb4589 | 2010-06-08 10:53:39 +0800 | [diff] [blame] | 692 | struct bsc_nat_acc_lst_entry *nat_entry, *bsc_entry; |
Holger Hans Peter Freyther | 28b08d6 | 2010-05-14 08:12:57 +0800 | [diff] [blame] | 693 | |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 694 | struct bsc_nat *nat = bsc_nat_alloc(); |
| 695 | struct bsc_connection *bsc = bsc_connection_alloc(nat); |
Holger Hans Peter Freyther | 1f04083 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 696 | bsc->cfg = bsc_config_alloc(nat, "foo"); |
| 697 | bsc_config_add_lac(bsc->cfg, 1234); |
Holger Hans Peter Freyther | 67b6d52 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 698 | bsc->cfg->acc_lst_name = "bsc"; |
| 699 | nat->acc_lst_name = "nat"; |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 700 | |
Holger Hans Peter Freyther | 8eb4589 | 2010-06-08 10:53:39 +0800 | [diff] [blame] | 701 | nat_lst = bsc_nat_acc_lst_get(nat, "nat"); |
| 702 | bsc_lst = bsc_nat_acc_lst_get(nat, "bsc"); |
| 703 | |
| 704 | bsc_entry = bsc_nat_acc_lst_entry_create(bsc_lst); |
| 705 | nat_entry = bsc_nat_acc_lst_entry_create(nat_lst); |
| 706 | |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 707 | for (i = 0; i < ARRAY_SIZE(cr_filter); ++i) { |
Holger Hans Peter Freyther | 9bd8bd7 | 2010-09-29 01:19:42 +0800 | [diff] [blame] | 708 | char *imsi; |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 709 | msgb_reset(msg); |
| 710 | copy_to_msg(msg, cr_filter[i].data, cr_filter[i].length); |
| 711 | |
Holger Hans Peter Freyther | b604471 | 2010-06-08 10:14:44 +0800 | [diff] [blame] | 712 | nat_lst = bsc_nat_acc_lst_get(nat, "nat"); |
| 713 | bsc_lst = bsc_nat_acc_lst_get(nat, "bsc"); |
Holger Hans Peter Freyther | 67b6d52 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 714 | |
Holger Hans Peter Freyther | 8eb4589 | 2010-06-08 10:53:39 +0800 | [diff] [blame] | 715 | bsc_parse_reg(nat_entry, &nat_entry->imsi_deny_re, &nat_entry->imsi_deny, |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 716 | cr_filter[i].nat_imsi_deny ? 1 : 0, |
| 717 | &cr_filter[i].nat_imsi_deny); |
Holger Hans Peter Freyther | 8eb4589 | 2010-06-08 10:53:39 +0800 | [diff] [blame] | 718 | bsc_parse_reg(bsc_entry, &bsc_entry->imsi_allow_re, &bsc_entry->imsi_allow, |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 719 | cr_filter[i].bsc_imsi_allow ? 1 : 0, |
| 720 | &cr_filter[i].bsc_imsi_allow); |
Holger Hans Peter Freyther | 8eb4589 | 2010-06-08 10:53:39 +0800 | [diff] [blame] | 721 | bsc_parse_reg(bsc_entry, &bsc_entry->imsi_deny_re, &bsc_entry->imsi_deny, |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 722 | cr_filter[i].bsc_imsi_deny ? 1 : 0, |
| 723 | &cr_filter[i].bsc_imsi_deny); |
| 724 | |
| 725 | parsed = bsc_nat_parse(msg); |
| 726 | if (!parsed) { |
| 727 | fprintf(stderr, "FAIL: Failed to parse the message\n"); |
| 728 | abort(); |
| 729 | } |
| 730 | |
Holger Hans Peter Freyther | 9bd8bd7 | 2010-09-29 01:19:42 +0800 | [diff] [blame] | 731 | res = bsc_nat_filter_sccp_cr(bsc, msg, parsed, &contype, &imsi); |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 732 | if (res != cr_filter[i].result) { |
| 733 | fprintf(stderr, "FAIL: Wrong result %d for test %d.\n", res, i); |
| 734 | abort(); |
| 735 | } |
| 736 | |
Holger Hans Peter Freyther | d5a2bc4 | 2010-05-16 02:00:40 +0800 | [diff] [blame] | 737 | if (contype != cr_filter[i].contype) { |
| 738 | fprintf(stderr, "FAIL: Wrong contype %d for test %d.\n", res, contype); |
| 739 | abort(); |
| 740 | } |
| 741 | |
Holger Hans Peter Freyther | 9bd8bd7 | 2010-09-29 01:19:42 +0800 | [diff] [blame] | 742 | talloc_steal(parsed, imsi); |
Holger Hans Peter Freyther | 13abb82 | 2010-05-14 19:49:35 +0800 | [diff] [blame] | 743 | talloc_free(parsed); |
Holger Hans Peter Freyther | 28b08d6 | 2010-05-14 08:12:57 +0800 | [diff] [blame] | 744 | } |
| 745 | |
Holger Hans Peter Freyther | 28b08d6 | 2010-05-14 08:12:57 +0800 | [diff] [blame] | 746 | msgb_free(msg); |
| 747 | } |
| 748 | |
Holger Hans Peter Freyther | a15e257 | 2010-09-15 05:20:40 +0800 | [diff] [blame] | 749 | static void test_dt_filter() |
| 750 | { |
| 751 | int i; |
| 752 | struct msgb *msg = msgb_alloc(4096, "test_dt_filter"); |
| 753 | struct bsc_nat_parsed *parsed; |
| 754 | |
| 755 | struct bsc_nat *nat = bsc_nat_alloc(); |
| 756 | struct bsc_connection *bsc = bsc_connection_alloc(nat); |
| 757 | struct sccp_connections *con = talloc_zero(0, struct sccp_connections); |
| 758 | |
Holger Hans Peter Freyther | 1f04083 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 759 | bsc->cfg = bsc_config_alloc(nat, "foo"); |
| 760 | bsc_config_add_lac(bsc->cfg, 23); |
Holger Hans Peter Freyther | a15e257 | 2010-09-15 05:20:40 +0800 | [diff] [blame] | 761 | con->bsc = bsc; |
| 762 | |
| 763 | msgb_reset(msg); |
| 764 | copy_to_msg(msg, id_resp, ARRAY_SIZE(id_resp)); |
| 765 | |
| 766 | parsed = bsc_nat_parse(msg); |
| 767 | if (!parsed) { |
| 768 | fprintf(stderr, "FAIL: Could not parse ID resp\n"); |
| 769 | abort(); |
| 770 | } |
| 771 | |
| 772 | if (parsed->bssap != BSSAP_MSG_DTAP) { |
| 773 | fprintf(stderr, "FAIL: It should be dtap\n"); |
| 774 | abort(); |
| 775 | } |
| 776 | |
| 777 | /* gsm_type is actually the size of the dtap */ |
| 778 | if (parsed->gsm_type < msgb_l3len(msg) - 3) { |
| 779 | fprintf(stderr, "FAIL: Not enough space for the content\n"); |
| 780 | abort(); |
| 781 | } |
| 782 | |
| 783 | if (bsc_nat_filter_dt(bsc, msg, con, parsed) != 1) { |
| 784 | fprintf(stderr, "FAIL: Should have passed..\n"); |
| 785 | abort(); |
| 786 | } |
| 787 | |
| 788 | /* just some basic length checking... */ |
| 789 | for (i = ARRAY_SIZE(id_resp); i >= 0; --i) { |
| 790 | msgb_reset(msg); |
| 791 | copy_to_msg(msg, id_resp, ARRAY_SIZE(id_resp)); |
| 792 | |
| 793 | parsed = bsc_nat_parse(msg); |
| 794 | if (!parsed) |
| 795 | continue; |
| 796 | |
| 797 | con->imsi_checked = 0; |
| 798 | bsc_nat_filter_dt(bsc, msg, con, parsed); |
| 799 | } |
| 800 | } |
| 801 | |
Holger Hans Peter Freyther | 0d5fdbb | 2010-10-21 14:46:57 +0200 | [diff] [blame] | 802 | static void test_setup_rewrite() |
| 803 | { |
| 804 | struct msgb *msg = msgb_alloc(4096, "test_dt_filter"); |
| 805 | struct msgb *out; |
| 806 | struct bsc_nat_parsed *parsed; |
| 807 | const char *imsi = "27408000001234"; |
| 808 | |
| 809 | struct bsc_nat *nat = bsc_nat_alloc(); |
| 810 | |
| 811 | /* a fake list */ |
| 812 | struct msg_entries entries; |
| 813 | struct msg_entry entry; |
| 814 | |
| 815 | INIT_LLIST_HEAD(&entries.entry); |
| 816 | entry.mcc = "274"; |
| 817 | entry.mnc = "08"; |
| 818 | entry.option = "^0([1-9])"; |
| 819 | entry.text = "0049"; |
| 820 | llist_add_tail(&entry.list, &entries.entry); |
| 821 | nat->num_rewr = &entries; |
| 822 | |
| 823 | /* verify that nothing changed */ |
| 824 | msgb_reset(msg); |
| 825 | copy_to_msg(msg, cc_setup_international, ARRAY_SIZE(cc_setup_international)); |
| 826 | parsed = bsc_nat_parse(msg); |
| 827 | if (!parsed) { |
| 828 | fprintf(stderr, "FAIL: Could not parse ID resp\n"); |
| 829 | abort(); |
| 830 | } |
| 831 | |
| 832 | out = bsc_nat_rewrite_setup(nat, msg, parsed, imsi); |
| 833 | if (msg != out) { |
| 834 | fprintf(stderr, "FAIL: The message should not have been changed\n"); |
| 835 | abort(); |
| 836 | } |
| 837 | |
| 838 | if (out->len != ARRAY_SIZE(cc_setup_international)) { |
| 839 | fprintf(stderr, "FAIL: Length of message changed\n"); |
| 840 | abort(); |
| 841 | } |
| 842 | |
| 843 | if (memcmp(out->data, cc_setup_international, out->len) != 0) { |
| 844 | fprintf(stderr, "FAIL: Content modified..\n"); |
| 845 | abort(); |
| 846 | } |
| 847 | talloc_free(parsed); |
| 848 | |
| 849 | /* verify that something in the message changes */ |
| 850 | msgb_reset(msg); |
| 851 | copy_to_msg(msg, cc_setup_national, ARRAY_SIZE(cc_setup_national)); |
| 852 | parsed = bsc_nat_parse(msg); |
| 853 | if (!parsed) { |
| 854 | fprintf(stderr, "FAIL: Could not parse ID resp\n"); |
| 855 | abort(); |
| 856 | } |
| 857 | |
| 858 | out = bsc_nat_rewrite_setup(nat, msg, parsed, imsi); |
| 859 | if (!out) { |
| 860 | fprintf(stderr, "FAIL: A new message should be created.\n"); |
| 861 | abort(); |
| 862 | } |
| 863 | |
| 864 | if (msg == out) { |
| 865 | fprintf(stderr, "FAIL: The message should have changed\n"); |
| 866 | abort(); |
| 867 | } |
| 868 | |
| 869 | if (out->len != ARRAY_SIZE(cc_setup_national_patched)) { |
| 870 | fprintf(stderr, "FAIL: Length is wrong.\n"); |
| 871 | abort(); |
| 872 | } |
| 873 | |
| 874 | if (memcmp(cc_setup_national_patched, out->data, out->len) != 0) { |
| 875 | fprintf(stderr, "FAIL: Data is wrong.\n"); |
| 876 | fprintf(stderr, "Data was: %s\n", hexdump(out->data, out->len)); |
| 877 | abort(); |
| 878 | } |
| 879 | |
| 880 | msgb_free(out); |
Holger Hans Peter Freyther | 34c48a6 | 2010-10-28 15:27:00 +0200 | [diff] [blame] | 881 | |
| 882 | /* Make sure that a wildcard is matching */ |
| 883 | entry.mnc = "*"; |
| 884 | msg = msgb_alloc(4096, "test_dt_filter"); |
| 885 | copy_to_msg(msg, cc_setup_national, ARRAY_SIZE(cc_setup_national)); |
| 886 | parsed = bsc_nat_parse(msg); |
| 887 | if (!parsed) { |
| 888 | fprintf(stderr, "FAIL: Could not parse ID resp\n"); |
| 889 | abort(); |
| 890 | } |
| 891 | |
| 892 | out = bsc_nat_rewrite_setup(nat, msg, parsed, imsi); |
| 893 | if (!out) { |
| 894 | fprintf(stderr, "FAIL: A new message should be created.\n"); |
| 895 | abort(); |
| 896 | } |
| 897 | |
| 898 | if (msg == out) { |
| 899 | fprintf(stderr, "FAIL: The message should have changed\n"); |
| 900 | abort(); |
| 901 | } |
| 902 | |
| 903 | if (out->len != ARRAY_SIZE(cc_setup_national_patched)) { |
| 904 | fprintf(stderr, "FAIL: Length is wrong.\n"); |
| 905 | abort(); |
| 906 | } |
| 907 | |
| 908 | if (memcmp(cc_setup_national_patched, out->data, out->len) != 0) { |
| 909 | fprintf(stderr, "FAIL: Data is wrong.\n"); |
| 910 | fprintf(stderr, "Data was: %s\n", hexdump(out->data, out->len)); |
| 911 | abort(); |
| 912 | } |
| 913 | |
| 914 | msgb_free(out); |
| 915 | |
| 916 | /* Make sure that a wildcard is matching */ |
| 917 | entry.mnc = "09"; |
| 918 | msg = msgb_alloc(4096, "test_dt_filter"); |
| 919 | copy_to_msg(msg, cc_setup_national, ARRAY_SIZE(cc_setup_national)); |
| 920 | parsed = bsc_nat_parse(msg); |
| 921 | if (!parsed) { |
| 922 | fprintf(stderr, "FAIL: Could not parse ID resp\n"); |
| 923 | abort(); |
| 924 | } |
| 925 | |
| 926 | out = bsc_nat_rewrite_setup(nat, msg, parsed, imsi); |
| 927 | if (out != msg) { |
| 928 | fprintf(stderr, "FAIL: The message should be unchanged.\n"); |
| 929 | abort(); |
| 930 | } |
| 931 | |
| 932 | if (out->len != ARRAY_SIZE(cc_setup_national)) { |
| 933 | fprintf(stderr, "FAIL: Foo\n"); |
| 934 | abort(); |
| 935 | } |
| 936 | |
| 937 | if (memcmp(out->data, cc_setup_national, ARRAY_SIZE(cc_setup_national)) != 0) { |
| 938 | fprintf(stderr, "FAIL: The message should really be unchanged.\n"); |
| 939 | abort(); |
| 940 | } |
| 941 | |
| 942 | msgb_free(out); |
Holger Hans Peter Freyther | 0d5fdbb | 2010-10-21 14:46:57 +0200 | [diff] [blame] | 943 | } |
| 944 | |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 945 | int main(int argc, char **argv) |
| 946 | { |
Holger Hans Peter Freyther | 38ecaa1 | 2010-06-15 20:18:40 +0800 | [diff] [blame] | 947 | struct log_target *stderr_target; |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 948 | |
Holger Hans Peter Freyther | a8dffc1 | 2010-07-30 02:53:14 +0800 | [diff] [blame] | 949 | sccp_set_log_area(DSCCP); |
Holger Hans Peter Freyther | 139f335 | 2010-07-05 13:29:42 +0800 | [diff] [blame] | 950 | log_init(&log_info); |
Holger Hans Peter Freyther | 38ecaa1 | 2010-06-15 20:18:40 +0800 | [diff] [blame] | 951 | stderr_target = log_target_create_stderr(); |
| 952 | log_add_target(stderr_target); |
| 953 | log_set_all_filter(stderr_target, 1); |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 954 | |
| 955 | test_filter(); |
Holger Hans Peter Freyther | d5deb33 | 2010-03-30 06:51:53 +0200 | [diff] [blame] | 956 | test_contrack(); |
Holger Hans Peter Freyther | d5deb33 | 2010-03-30 06:51:53 +0200 | [diff] [blame] | 957 | test_paging(); |
Holger Hans Peter Freyther | 8917998 | 2010-04-01 03:55:27 +0200 | [diff] [blame] | 958 | test_mgcp_ass_tracking(); |
| 959 | test_mgcp_find(); |
Holger Hans Peter Freyther | acd6420 | 2010-04-01 06:48:52 +0200 | [diff] [blame] | 960 | test_mgcp_rewrite(); |
Holger Hans Peter Freyther | 9fec010 | 2010-04-01 10:16:28 +0200 | [diff] [blame] | 961 | test_mgcp_parse(); |
Holger Hans Peter Freyther | 28b08d6 | 2010-05-14 08:12:57 +0800 | [diff] [blame] | 962 | test_cr_filter(); |
Holger Hans Peter Freyther | a15e257 | 2010-09-15 05:20:40 +0800 | [diff] [blame] | 963 | test_dt_filter(); |
Holger Hans Peter Freyther | 0d5fdbb | 2010-10-21 14:46:57 +0200 | [diff] [blame] | 964 | test_setup_rewrite(); |
Holger Hans Peter Freyther | f75a680 | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 965 | return 0; |
| 966 | } |
Holger Hans Peter Freyther | b63a9f8 | 2010-06-15 18:48:36 +0800 | [diff] [blame] | 967 | |
| 968 | void input_event() |
| 969 | {} |
| 970 | int nm_state_event() |
| 971 | { |
| 972 | return -1; |
| 973 | } |
| 974 | |