Holger Hans Peter Freyther | f0bc075 | 2011-01-06 19:32:52 +0100 | [diff] [blame] | 1 | /* |
Holger Hans Peter Freyther | 171817c | 2014-09-01 10:50:22 +0200 | [diff] [blame] | 2 | * (C) 2011-2012,2014 by Holger Hans Peter Freyther <zecke@selfish.org> |
| 3 | * (C) 2011-2012,2014 by On-Waves |
Holger Hans Peter Freyther | f0bc075 | 2011-01-06 19:32:52 +0100 | [diff] [blame] | 4 | * All Rights Reserved |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU Affero General Public License as published by |
| 8 | * the Free Software Foundation; either version 3 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU Affero General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Affero General Public License |
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
Jacob Erlbeck | acd8d52 | 2014-01-07 11:38:22 +0100 | [diff] [blame] | 19 | #undef _GNU_SOURCE |
| 20 | #define _GNU_SOURCE |
Holger Hans Peter Freyther | f0bc075 | 2011-01-06 19:32:52 +0100 | [diff] [blame] | 21 | |
| 22 | #include <openbsc/mgcp.h> |
Jacob Erlbeck | ce00725 | 2014-06-12 12:28:12 +0200 | [diff] [blame] | 23 | #include <openbsc/vty.h> |
Holger Hans Peter Freyther | 49e170b | 2011-02-28 14:37:03 +0100 | [diff] [blame] | 24 | #include <openbsc/mgcp_internal.h> |
Holger Hans Peter Freyther | f0bc075 | 2011-01-06 19:32:52 +0100 | [diff] [blame] | 25 | |
Holger Hans Peter Freyther | 2d59cc6 | 2011-05-12 16:02:07 +0200 | [diff] [blame] | 26 | #include <osmocom/core/application.h> |
Pablo Neira Ayuso | dd5fff4 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 27 | #include <osmocom/core/talloc.h> |
Holger Hans Peter Freyther | f0bc075 | 2011-01-06 19:32:52 +0100 | [diff] [blame] | 28 | #include <string.h> |
Holger Hans Peter Freyther | faa6793 | 2012-10-22 18:09:35 +0200 | [diff] [blame] | 29 | #include <limits.h> |
Jacob Erlbeck | acd8d52 | 2014-01-07 11:38:22 +0100 | [diff] [blame] | 30 | #include <dlfcn.h> |
Jacob Erlbeck | 49677bd | 2014-01-30 21:01:33 +0100 | [diff] [blame] | 31 | #include <time.h> |
Holger Hans Peter Freyther | e5d57f6 | 2014-02-03 13:25:42 +0100 | [diff] [blame] | 32 | #include <math.h> |
Holger Hans Peter Freyther | f0bc075 | 2011-01-06 19:32:52 +0100 | [diff] [blame] | 33 | |
Jacob Erlbeck | e7060c4 | 2013-11-29 13:43:44 +0100 | [diff] [blame] | 34 | char *strline_r(char *str, char **saveptr); |
| 35 | |
| 36 | const char *strline_test_data = |
| 37 | "one CR\r" |
| 38 | "two CR\r" |
| 39 | "\r" |
| 40 | "one CRLF\r\n" |
| 41 | "two CRLF\r\n" |
| 42 | "\r\n" |
| 43 | "one LF\n" |
| 44 | "two LF\n" |
| 45 | "\n" |
| 46 | "mixed (4 lines)\r\r\n\n\r\n"; |
| 47 | |
| 48 | #define EXPECTED_NUMBER_OF_LINES 13 |
| 49 | |
| 50 | static void test_strline(void) |
| 51 | { |
| 52 | char *save = NULL; |
| 53 | char *line; |
| 54 | char buf[2048]; |
| 55 | int counter = 0; |
| 56 | |
| 57 | strncpy(buf, strline_test_data, sizeof(buf)); |
| 58 | |
| 59 | for (line = strline_r(buf, &save); line; |
| 60 | line = strline_r(NULL, &save)) { |
| 61 | printf("line: '%s'\n", line); |
| 62 | counter++; |
| 63 | } |
| 64 | |
| 65 | OSMO_ASSERT(counter == EXPECTED_NUMBER_OF_LINES); |
| 66 | } |
| 67 | |
Harald Welte | 834f3f1 | 2012-01-27 00:00:44 +0100 | [diff] [blame] | 68 | #define AUEP1 "AUEP 158663169 ds/e1-1/2@172.16.6.66 MGCP 1.0\r\n" |
Harald Welte | a7c9a92 | 2012-01-27 00:36:56 +0100 | [diff] [blame] | 69 | #define AUEP1_RET "200 158663169 OK\r\n" |
Harald Welte | 834f3f1 | 2012-01-27 00:00:44 +0100 | [diff] [blame] | 70 | #define AUEP2 "AUEP 18983213 ds/e1-2/1@172.16.6.66 MGCP 1.0\r\n" |
Harald Welte | a7c9a92 | 2012-01-27 00:36:56 +0100 | [diff] [blame] | 71 | #define AUEP2_RET "500 18983213 FAIL\r\n" |
Holger Hans Peter Freyther | 0a6455c | 2012-03-16 09:53:49 +0100 | [diff] [blame] | 72 | #define EMPTY "\r\n" |
| 73 | #define EMPTY_RET NULL |
| 74 | #define SHORT "CRCX \r\n" |
| 75 | #define SHORT_RET "510 000000 FAIL\r\n" |
| 76 | |
Holger Hans Peter Freyther | 74645f4 | 2012-12-10 12:54:57 +0100 | [diff] [blame] | 77 | #define MDCX_WRONG_EP "MDCX 18983213 ds/e1-3/1@172.16.6.66 MGCP 1.0\r\n" |
| 78 | #define MDCX_ERR_RET "510 18983213 FAIL\r\n" |
| 79 | #define MDCX_UNALLOCATED "MDCX 18983214 ds/e1-1/2@172.16.6.66 MGCP 1.0\r\n" |
| 80 | #define MDCX_RET "400 18983214 FAIL\r\n" |
| 81 | #define MDCX3 "MDCX 18983215 1@mgw MGCP 1.0\r\n" |
| 82 | #define MDCX3_RET "200 18983215 OK\r\n" \ |
| 83 | "I: 1\n" \ |
| 84 | "\n" \ |
| 85 | "v=0\r\n" \ |
| 86 | "o=- 1 23 IN IP4 0.0.0.0\r\n" \ |
Holger Hans Peter Freyther | 37ae84a | 2014-11-20 23:17:32 +0100 | [diff] [blame] | 87 | "s=-\r\n" \ |
Holger Hans Peter Freyther | 74645f4 | 2012-12-10 12:54:57 +0100 | [diff] [blame] | 88 | "c=IN IP4 0.0.0.0\r\n" \ |
| 89 | "t=0 0\r\n" \ |
| 90 | "m=audio 0 RTP/AVP 126\r\n" \ |
Jacob Erlbeck | e91324d | 2013-12-10 13:09:37 +0100 | [diff] [blame] | 91 | "a=rtpmap:126 AMR/8000\r\n" \ |
| 92 | "a=ptime:20\r\n" |
Jacob Erlbeck | ce00725 | 2014-06-12 12:28:12 +0200 | [diff] [blame] | 93 | #define MDCX3_FMTP_RET "200 18983215 OK\r\n" \ |
| 94 | "I: 3\n" \ |
| 95 | "\n" \ |
| 96 | "v=0\r\n" \ |
| 97 | "o=- 3 23 IN IP4 0.0.0.0\r\n" \ |
Holger Hans Peter Freyther | 37ae84a | 2014-11-20 23:17:32 +0100 | [diff] [blame] | 98 | "s=-\r\n" \ |
Jacob Erlbeck | ce00725 | 2014-06-12 12:28:12 +0200 | [diff] [blame] | 99 | "c=IN IP4 0.0.0.0\r\n" \ |
| 100 | "t=0 0\r\n" \ |
| 101 | "m=audio 0 RTP/AVP 126\r\n" \ |
| 102 | "a=rtpmap:126 AMR/8000\r\n" \ |
| 103 | "a=fmtp:126 0/1/2\r\n" \ |
| 104 | "a=ptime:20\r\n" |
Jacob Erlbeck | fe9896f | 2013-11-29 13:43:45 +0100 | [diff] [blame] | 105 | #define MDCX4 "MDCX 18983216 1@mgw MGCP 1.0\r\n" \ |
Jacob Erlbeck | a4cc7cf | 2013-12-19 12:20:49 +0100 | [diff] [blame] | 106 | "M: sendrecv\r" \ |
Jacob Erlbeck | fe9896f | 2013-11-29 13:43:45 +0100 | [diff] [blame] | 107 | "C: 2\r\n" \ |
| 108 | "I: 1\r\n" \ |
| 109 | "L: p:20, a:AMR, nt:IN\r\n" \ |
| 110 | "\n" \ |
| 111 | "v=0\r\n" \ |
| 112 | "o=- 1 23 IN IP4 0.0.0.0\r\n" \ |
| 113 | "c=IN IP4 0.0.0.0\r\n" \ |
| 114 | "t=0 0\r\n" \ |
| 115 | "m=audio 4441 RTP/AVP 99\r\n" \ |
Jacob Erlbeck | 07a25f7 | 2013-12-10 13:09:37 +0100 | [diff] [blame] | 116 | "a=rtpmap:99 AMR/8000\r\n" \ |
| 117 | "a=ptime:40\r\n" |
| 118 | #define MDCX4_RET(Ident) "200 " Ident " OK\r\n" \ |
Jacob Erlbeck | fe9896f | 2013-11-29 13:43:45 +0100 | [diff] [blame] | 119 | "I: 1\n" \ |
| 120 | "\n" \ |
| 121 | "v=0\r\n" \ |
| 122 | "o=- 1 23 IN IP4 0.0.0.0\r\n" \ |
Holger Hans Peter Freyther | 37ae84a | 2014-11-20 23:17:32 +0100 | [diff] [blame] | 123 | "s=-\r\n" \ |
Jacob Erlbeck | fe9896f | 2013-11-29 13:43:45 +0100 | [diff] [blame] | 124 | "c=IN IP4 0.0.0.0\r\n" \ |
| 125 | "t=0 0\r\n" \ |
| 126 | "m=audio 0 RTP/AVP 126\r\n" \ |
Jacob Erlbeck | e91324d | 2013-12-10 13:09:37 +0100 | [diff] [blame] | 127 | "a=rtpmap:126 AMR/8000\r\n" \ |
| 128 | "a=ptime:20\r\n" |
Holger Hans Peter Freyther | 74645f4 | 2012-12-10 12:54:57 +0100 | [diff] [blame] | 129 | |
Jacob Erlbeck | 07a25f7 | 2013-12-10 13:09:37 +0100 | [diff] [blame] | 130 | #define MDCX4_PT1 "MDCX 18983217 1@mgw MGCP 1.0\r\n" \ |
Jacob Erlbeck | a4cc7cf | 2013-12-19 12:20:49 +0100 | [diff] [blame] | 131 | "M: sendrecv\r" \ |
Jacob Erlbeck | 07a25f7 | 2013-12-10 13:09:37 +0100 | [diff] [blame] | 132 | "C: 2\r\n" \ |
| 133 | "I: 1\r\n" \ |
| 134 | "L: p:20-40, a:AMR, nt:IN\r\n" \ |
| 135 | "\n" \ |
| 136 | "v=0\r\n" \ |
| 137 | "o=- 1 23 IN IP4 0.0.0.0\r\n" \ |
| 138 | "c=IN IP4 0.0.0.0\r\n" \ |
| 139 | "t=0 0\r\n" \ |
| 140 | "m=audio 4441 RTP/AVP 99\r\n" \ |
| 141 | "a=rtpmap:99 AMR/8000\r\n" \ |
| 142 | "a=ptime:40\r\n" |
| 143 | |
| 144 | #define MDCX4_PT2 "MDCX 18983218 1@mgw MGCP 1.0\r\n" \ |
Jacob Erlbeck | a4cc7cf | 2013-12-19 12:20:49 +0100 | [diff] [blame] | 145 | "M: sendrecv\r" \ |
Jacob Erlbeck | 07a25f7 | 2013-12-10 13:09:37 +0100 | [diff] [blame] | 146 | "C: 2\r\n" \ |
| 147 | "I: 1\r\n" \ |
| 148 | "L: p:20-20, a:AMR, nt:IN\r\n" \ |
| 149 | "\n" \ |
| 150 | "v=0\r\n" \ |
| 151 | "o=- 1 23 IN IP4 0.0.0.0\r\n" \ |
| 152 | "c=IN IP4 0.0.0.0\r\n" \ |
| 153 | "t=0 0\r\n" \ |
| 154 | "m=audio 4441 RTP/AVP 99\r\n" \ |
| 155 | "a=rtpmap:99 AMR/8000\r\n" \ |
| 156 | "a=ptime:40\r\n" |
| 157 | |
| 158 | #define MDCX4_PT3 "MDCX 18983219 1@mgw MGCP 1.0\r\n" \ |
Jacob Erlbeck | a4cc7cf | 2013-12-19 12:20:49 +0100 | [diff] [blame] | 159 | "M: sendrecv\r" \ |
Jacob Erlbeck | 07a25f7 | 2013-12-10 13:09:37 +0100 | [diff] [blame] | 160 | "C: 2\r\n" \ |
| 161 | "I: 1\r\n" \ |
| 162 | "L: a:AMR, nt:IN\r\n" \ |
| 163 | "\n" \ |
| 164 | "v=0\r\n" \ |
| 165 | "o=- 1 23 IN IP4 0.0.0.0\r\n" \ |
| 166 | "c=IN IP4 0.0.0.0\r\n" \ |
| 167 | "t=0 0\r\n" \ |
| 168 | "m=audio 4441 RTP/AVP 99\r\n" \ |
| 169 | "a=rtpmap:99 AMR/8000\r\n" \ |
| 170 | "a=ptime:40\r\n" |
| 171 | |
Jacob Erlbeck | a4cc7cf | 2013-12-19 12:20:49 +0100 | [diff] [blame] | 172 | #define MDCX4_SO "MDCX 18983220 1@mgw MGCP 1.0\r\n" \ |
| 173 | "M: sendonly\r" \ |
| 174 | "C: 2\r\n" \ |
| 175 | "I: 1\r\n" \ |
| 176 | "L: p:20, a:AMR, nt:IN\r\n" \ |
| 177 | "\n" \ |
| 178 | "v=0\r\n" \ |
| 179 | "o=- 1 23 IN IP4 0.0.0.0\r\n" \ |
| 180 | "c=IN IP4 0.0.0.0\r\n" \ |
| 181 | "t=0 0\r\n" \ |
| 182 | "m=audio 4441 RTP/AVP 99\r\n" \ |
| 183 | "a=rtpmap:99 AMR/8000\r\n" \ |
| 184 | "a=ptime:40\r\n" |
| 185 | |
Jacob Erlbeck | 0557c00 | 2014-05-09 19:42:17 +0200 | [diff] [blame] | 186 | #define MDCX4_RO "MDCX 18983221 1@mgw MGCP 1.0\r\n" \ |
| 187 | "M: recvonly\r" \ |
| 188 | "C: 2\r\n" \ |
| 189 | "I: 1\r\n" \ |
| 190 | "L: p:20, a:AMR, nt:IN\r\n" |
| 191 | |
Holger Hans Peter Freyther | 0a6455c | 2012-03-16 09:53:49 +0100 | [diff] [blame] | 192 | #define SHORT2 "CRCX 1" |
| 193 | #define SHORT2_RET "510 000000 FAIL\r\n" |
| 194 | #define SHORT3 "CRCX 1 1@mgw" |
| 195 | #define SHORT4 "CRCX 1 1@mgw MGCP" |
| 196 | #define SHORT5 "CRCX 1 1@mgw MGCP 1.0" |
Harald Welte | a7c9a92 | 2012-01-27 00:36:56 +0100 | [diff] [blame] | 197 | |
Harald Welte | ca765cd | 2012-01-27 00:37:23 +0100 | [diff] [blame] | 198 | #define CRCX "CRCX 2 1@mgw MGCP 1.0\r\n" \ |
Jacob Erlbeck | a4cc7cf | 2013-12-19 12:20:49 +0100 | [diff] [blame] | 199 | "M: recvonly\r\n" \ |
Harald Welte | ca765cd | 2012-01-27 00:37:23 +0100 | [diff] [blame] | 200 | "C: 2\r\n" \ |
Holger Hans Peter Freyther | 67f103e | 2014-05-22 15:03:10 +0200 | [diff] [blame] | 201 | "X\r\n" \ |
Jacob Erlbeck | 07a25f7 | 2013-12-10 13:09:37 +0100 | [diff] [blame] | 202 | "L: p:20\r\n" \ |
Harald Welte | ca765cd | 2012-01-27 00:37:23 +0100 | [diff] [blame] | 203 | "\r\n" \ |
| 204 | "v=0\r\n" \ |
| 205 | "c=IN IP4 123.12.12.123\r\n" \ |
| 206 | "m=audio 5904 RTP/AVP 97\r\n" \ |
Jacob Erlbeck | 07a25f7 | 2013-12-10 13:09:37 +0100 | [diff] [blame] | 207 | "a=rtpmap:97 GSM-EFR/8000\r\n" \ |
| 208 | "a=ptime:40\r\n" |
Harald Welte | ca765cd | 2012-01-27 00:37:23 +0100 | [diff] [blame] | 209 | |
| 210 | #define CRCX_RET "200 2 OK\r\n" \ |
| 211 | "I: 1\n" \ |
| 212 | "\n" \ |
| 213 | "v=0\r\n" \ |
| 214 | "o=- 1 23 IN IP4 0.0.0.0\r\n" \ |
Holger Hans Peter Freyther | 37ae84a | 2014-11-20 23:17:32 +0100 | [diff] [blame] | 215 | "s=-\r\n" \ |
Harald Welte | ca765cd | 2012-01-27 00:37:23 +0100 | [diff] [blame] | 216 | "c=IN IP4 0.0.0.0\r\n" \ |
| 217 | "t=0 0\r\n" \ |
| 218 | "m=audio 0 RTP/AVP 126\r\n" \ |
Jacob Erlbeck | e91324d | 2013-12-10 13:09:37 +0100 | [diff] [blame] | 219 | "a=rtpmap:126 AMR/8000\r\n" \ |
| 220 | "a=ptime:20\r\n" |
Harald Welte | ca765cd | 2012-01-27 00:37:23 +0100 | [diff] [blame] | 221 | |
Holger Hans Peter Freyther | 60e0992 | 2014-11-19 16:04:45 +0100 | [diff] [blame] | 222 | #define CRCX_RET_NO_RTPMAP "200 2 OK\r\n" \ |
| 223 | "I: 1\n" \ |
| 224 | "\n" \ |
| 225 | "v=0\r\n" \ |
| 226 | "o=- 1 23 IN IP4 0.0.0.0\r\n" \ |
Holger Hans Peter Freyther | 37ae84a | 2014-11-20 23:17:32 +0100 | [diff] [blame] | 227 | "s=-\r\n" \ |
Holger Hans Peter Freyther | 60e0992 | 2014-11-19 16:04:45 +0100 | [diff] [blame] | 228 | "c=IN IP4 0.0.0.0\r\n" \ |
| 229 | "t=0 0\r\n" \ |
| 230 | "m=audio 0 RTP/AVP 126\r\n" \ |
| 231 | "a=ptime:20\r\n" |
| 232 | |
Jacob Erlbeck | ce00725 | 2014-06-12 12:28:12 +0200 | [diff] [blame] | 233 | #define CRCX_FMTP_RET "200 2 OK\r\n" \ |
| 234 | "I: 3\n" \ |
| 235 | "\n" \ |
| 236 | "v=0\r\n" \ |
| 237 | "o=- 3 23 IN IP4 0.0.0.0\r\n" \ |
Holger Hans Peter Freyther | 37ae84a | 2014-11-20 23:17:32 +0100 | [diff] [blame] | 238 | "s=-\r\n" \ |
Jacob Erlbeck | ce00725 | 2014-06-12 12:28:12 +0200 | [diff] [blame] | 239 | "c=IN IP4 0.0.0.0\r\n" \ |
| 240 | "t=0 0\r\n" \ |
| 241 | "m=audio 0 RTP/AVP 126\r\n" \ |
| 242 | "a=rtpmap:126 AMR/8000\r\n" \ |
| 243 | "a=fmtp:126 0/1/2\r\n" \ |
| 244 | "a=ptime:20\r\n" |
| 245 | |
Harald Welte | ca765cd | 2012-01-27 00:37:23 +0100 | [diff] [blame] | 246 | #define CRCX_ZYN "CRCX 2 1@mgw MGCP 1.0\r" \ |
Jacob Erlbeck | a4cc7cf | 2013-12-19 12:20:49 +0100 | [diff] [blame] | 247 | "M: recvonly\r" \ |
Harald Welte | ca765cd | 2012-01-27 00:37:23 +0100 | [diff] [blame] | 248 | "C: 2\r\r" \ |
| 249 | "v=0\r" \ |
| 250 | "c=IN IP4 123.12.12.123\r" \ |
| 251 | "m=audio 5904 RTP/AVP 97\r" \ |
| 252 | "a=rtpmap:97 GSM-EFR/8000\r" |
Harald Welte | a7c9a92 | 2012-01-27 00:36:56 +0100 | [diff] [blame] | 253 | |
Holger Hans Peter Freyther | 0e8e18e | 2012-12-07 14:42:03 +0100 | [diff] [blame] | 254 | #define CRCX_ZYN_RET "200 2 OK\r\n" \ |
| 255 | "I: 2\n" \ |
| 256 | "\n" \ |
| 257 | "v=0\r\n" \ |
| 258 | "o=- 2 23 IN IP4 0.0.0.0\r\n" \ |
Holger Hans Peter Freyther | 37ae84a | 2014-11-20 23:17:32 +0100 | [diff] [blame] | 259 | "s=-\r\n" \ |
Holger Hans Peter Freyther | 0e8e18e | 2012-12-07 14:42:03 +0100 | [diff] [blame] | 260 | "c=IN IP4 0.0.0.0\r\n" \ |
| 261 | "t=0 0\r\n" \ |
| 262 | "m=audio 0 RTP/AVP 126\r\n" \ |
Jacob Erlbeck | e91324d | 2013-12-10 13:09:37 +0100 | [diff] [blame] | 263 | "a=rtpmap:126 AMR/8000\r\n" \ |
| 264 | "a=ptime:20\r\n" |
Holger Hans Peter Freyther | 0e8e18e | 2012-12-07 14:42:03 +0100 | [diff] [blame] | 265 | |
Holger Hans Peter Freyther | 8fc6d08 | 2012-09-14 17:18:12 +0200 | [diff] [blame] | 266 | #define DLCX "DLCX 7 1@mgw MGCP 1.0\r\n" \ |
| 267 | "C: 2\r\n" |
| 268 | |
| 269 | #define DLCX_RET "250 7 OK\r\n" \ |
Jacob Erlbeck | a2528da | 2013-11-25 12:53:28 +0100 | [diff] [blame] | 270 | "P: PS=0, OS=0, PR=0, OR=0, PL=0, JI=0\r\n" \ |
| 271 | "X-Osmo-CP: EC TIS=0, TOS=0, TIR=0, TOR=0\r\n" |
Holger Hans Peter Freyther | 8fc6d08 | 2012-09-14 17:18:12 +0200 | [diff] [blame] | 272 | |
Holger Hans Peter Freyther | 46880c2 | 2012-11-29 12:54:22 +0100 | [diff] [blame] | 273 | #define RQNT "RQNT 186908780 1@mgw MGCP 1.0\r\n" \ |
| 274 | "X: B244F267488\r\n" \ |
| 275 | "S: D/9\r\n" |
| 276 | |
Holger Hans Peter Freyther | cd25695 | 2012-12-07 15:04:07 +0100 | [diff] [blame] | 277 | #define RQNT2 "RQNT 186908781 1@mgw MGCP 1.0\r\n" \ |
Holger Hans Peter Freyther | 46880c2 | 2012-11-29 12:54:22 +0100 | [diff] [blame] | 278 | "X: ADD4F26746F\r\n" \ |
| 279 | "R: D/[0-9#*](N), G/ft, fxr/t38\r\n" |
| 280 | |
Holger Hans Peter Freyther | cd25695 | 2012-12-07 15:04:07 +0100 | [diff] [blame] | 281 | #define RQNT1_RET "200 186908780 OK\r\n" |
| 282 | #define RQNT2_RET "200 186908781 OK\r\n" |
Holger Hans Peter Freyther | 8fc6d08 | 2012-09-14 17:18:12 +0200 | [diff] [blame] | 283 | |
Jacob Erlbeck | fe9896f | 2013-11-29 13:43:45 +0100 | [diff] [blame] | 284 | #define PTYPE_IGNORE 0 /* == default initializer */ |
| 285 | #define PTYPE_NONE 128 |
| 286 | #define PTYPE_NYI PTYPE_NONE |
| 287 | |
Holger Hans Peter Freyther | 171817c | 2014-09-01 10:50:22 +0200 | [diff] [blame] | 288 | #define CRCX_MULT_1 "CRCX 2 1@mgw MGCP 1.0\r\n" \ |
| 289 | "M: recvonly\r\n" \ |
| 290 | "C: 2\r\n" \ |
| 291 | "X\r\n" \ |
| 292 | "L: p:20\r\n" \ |
| 293 | "\r\n" \ |
| 294 | "v=0\r\n" \ |
| 295 | "c=IN IP4 123.12.12.123\r\n" \ |
| 296 | "m=audio 5904 RTP/AVP 18 97\r\n"\ |
| 297 | "a=rtpmap:18 G729/8000\r\n" \ |
| 298 | "a=rtpmap:97 GSM-EFR/8000\r\n" \ |
| 299 | "a=ptime:40\r\n" |
| 300 | |
| 301 | #define CRCX_MULT_2 "CRCX 2 2@mgw MGCP 1.0\r\n" \ |
| 302 | "M: recvonly\r\n" \ |
| 303 | "C: 2\r\n" \ |
| 304 | "X\r\n" \ |
| 305 | "L: p:20\r\n" \ |
| 306 | "\r\n" \ |
| 307 | "v=0\r\n" \ |
| 308 | "c=IN IP4 123.12.12.123\r\n" \ |
| 309 | "m=audio 5904 RTP/AVP 18 97 101\r\n"\ |
| 310 | "a=rtpmap:18 G729/8000\r\n" \ |
| 311 | "a=rtpmap:97 GSM-EFR/8000\r\n" \ |
| 312 | "a=rtpmap:101 FOO/8000\r\n" \ |
| 313 | "a=ptime:40\r\n" |
| 314 | |
| 315 | #define CRCX_MULT_3 "CRCX 2 3@mgw MGCP 1.0\r\n" \ |
| 316 | "M: recvonly\r\n" \ |
| 317 | "C: 2\r\n" \ |
| 318 | "X\r\n" \ |
| 319 | "L: p:20\r\n" \ |
| 320 | "\r\n" \ |
| 321 | "v=0\r\n" \ |
| 322 | "c=IN IP4 123.12.12.123\r\n" \ |
| 323 | "m=audio 5904 RTP/AVP\r\n" \ |
| 324 | "a=rtpmap:18 G729/8000\r\n" \ |
| 325 | "a=rtpmap:97 GSM-EFR/8000\r\n" \ |
| 326 | "a=rtpmap:101 FOO/8000\r\n" \ |
| 327 | "a=ptime:40\r\n" |
| 328 | |
| 329 | #define CRCX_MULT_4 "CRCX 2 4@mgw MGCP 1.0\r\n" \ |
| 330 | "M: recvonly\r\n" \ |
| 331 | "C: 2\r\n" \ |
| 332 | "X\r\n" \ |
| 333 | "L: p:20\r\n" \ |
| 334 | "\r\n" \ |
| 335 | "v=0\r\n" \ |
| 336 | "c=IN IP4 123.12.12.123\r\n" \ |
| 337 | "m=audio 5904 RTP/AVP 18\r\n" \ |
| 338 | "a=rtpmap:18 G729/8000\r\n" \ |
| 339 | "a=rtpmap:97 GSM-EFR/8000\r\n" \ |
| 340 | "a=rtpmap:101 FOO/8000\r\n" \ |
| 341 | "a=ptime:40\r\n" |
| 342 | |
Holger Hans Peter Freyther | ac27e82 | 2015-08-14 15:43:06 +0200 | [diff] [blame] | 343 | #define CRCX_MULT_GSM_EXACT \ |
| 344 | "CRCX 259260421 5@mgw MGCP 1.0\r\n" \ |
| 345 | "C: 1355c6041e\r\n" \ |
| 346 | "I: 3\r\n" \ |
| 347 | "L: p:20, a:GSM, nt:IN\r\n" \ |
| 348 | "M: recvonly\r\n" \ |
| 349 | "\r\n" \ |
| 350 | "v=0\r\n" \ |
| 351 | "o=- 1439038275 1439038275 IN IP4 192.168.181.247\r\n" \ |
| 352 | "s=-\r\nc=IN IP4 192.168.181.247\r\n" \ |
Holger Hans Peter Freyther | a267b33 | 2015-08-17 15:19:57 +0200 | [diff] [blame] | 353 | "t=0 0\r\nm=audio 29084 RTP/AVP 255 0 8 3 18 4 96 97 101\r\n" \ |
Holger Hans Peter Freyther | ac27e82 | 2015-08-14 15:43:06 +0200 | [diff] [blame] | 354 | "a=rtpmap:0 PCMU/8000\r\n" \ |
| 355 | "a=rtpmap:8 PCMA/8000\r\n" \ |
| 356 | "a=rtpmap:3 gsm/8000\r\n" \ |
| 357 | "a=rtpmap:18 G729/8000\r\n" \ |
| 358 | "a=fmtp:18 annexb=no\r\n" \ |
| 359 | "a=rtpmap:4 G723/8000\r\n" \ |
| 360 | "a=rtpmap:96 iLBC/8000\r\n" \ |
| 361 | "a=fmtp:96 mode=20\r\n" \ |
| 362 | "a=rtpmap:97 iLBC/8000\r\n" \ |
| 363 | "a=fmtp:97 mode=30\r\n" \ |
| 364 | "a=rtpmap:101 telephone-event/8000\r\n" \ |
| 365 | "a=fmtp:101 0-15\r\n" \ |
| 366 | "a=recvonly\r\n" |
Holger Hans Peter Freyther | a0a8e45 | 2015-08-17 15:50:01 +0200 | [diff] [blame] | 367 | #define MDCX_NAT_DUMMY \ |
| 368 | "MDCX 23 5@mgw MGCP 1.0\r\n" \ |
| 369 | "C: 1355c6041e\r\n" \ |
| 370 | "\r\n" \ |
| 371 | "c=IN IP4 8.8.8.8\r\n" \ |
| 372 | "m=audio 16434 RTP/AVP 255\r\n" |
| 373 | |
Holger Hans Peter Freyther | ac27e82 | 2015-08-14 15:43:06 +0200 | [diff] [blame] | 374 | |
Harald Welte | a7c9a92 | 2012-01-27 00:36:56 +0100 | [diff] [blame] | 375 | struct mgcp_test { |
| 376 | const char *name; |
| 377 | const char *req; |
| 378 | const char *exp_resp; |
Jacob Erlbeck | fe9896f | 2013-11-29 13:43:45 +0100 | [diff] [blame] | 379 | int exp_net_ptype; |
| 380 | int exp_bts_ptype; |
Jacob Erlbeck | ce00725 | 2014-06-12 12:28:12 +0200 | [diff] [blame] | 381 | |
| 382 | const char *extra_fmtp; |
Harald Welte | a7c9a92 | 2012-01-27 00:36:56 +0100 | [diff] [blame] | 383 | }; |
| 384 | |
Holger Hans Peter Freyther | 0e8e18e | 2012-12-07 14:42:03 +0100 | [diff] [blame] | 385 | static const struct mgcp_test tests[] = { |
Harald Welte | a7c9a92 | 2012-01-27 00:36:56 +0100 | [diff] [blame] | 386 | { "AUEP1", AUEP1, AUEP1_RET }, |
| 387 | { "AUEP2", AUEP2, AUEP2_RET }, |
Holger Hans Peter Freyther | 74645f4 | 2012-12-10 12:54:57 +0100 | [diff] [blame] | 388 | { "MDCX1", MDCX_WRONG_EP, MDCX_ERR_RET }, |
| 389 | { "MDCX2", MDCX_UNALLOCATED, MDCX_RET }, |
Jacob Erlbeck | e3440c7 | 2013-11-29 13:43:49 +0100 | [diff] [blame] | 390 | { "CRCX", CRCX, CRCX_RET, 97, 126 }, |
Jacob Erlbeck | fe9896f | 2013-11-29 13:43:45 +0100 | [diff] [blame] | 391 | { "MDCX3", MDCX3, MDCX3_RET, PTYPE_NONE, 126 }, |
Jacob Erlbeck | 07a25f7 | 2013-12-10 13:09:37 +0100 | [diff] [blame] | 392 | { "MDCX4", MDCX4, MDCX4_RET("18983216"), 99, 126 }, |
| 393 | { "MDCX4_PT1", MDCX4_PT1, MDCX4_RET("18983217"), 99, 126 }, |
| 394 | { "MDCX4_PT2", MDCX4_PT2, MDCX4_RET("18983218"), 99, 126 }, |
| 395 | { "MDCX4_PT3", MDCX4_PT3, MDCX4_RET("18983219"), 99, 126 }, |
Jacob Erlbeck | a4cc7cf | 2013-12-19 12:20:49 +0100 | [diff] [blame] | 396 | { "MDCX4_SO", MDCX4_SO, MDCX4_RET("18983220"), 99, 126 }, |
Jacob Erlbeck | 0557c00 | 2014-05-09 19:42:17 +0200 | [diff] [blame] | 397 | { "MDCX4_RO", MDCX4_RO, MDCX4_RET("18983221"), PTYPE_IGNORE, 126 }, |
Jacob Erlbeck | fe9896f | 2013-11-29 13:43:45 +0100 | [diff] [blame] | 398 | { "DLCX", DLCX, DLCX_RET, -1, -1 }, |
Jacob Erlbeck | e3440c7 | 2013-11-29 13:43:49 +0100 | [diff] [blame] | 399 | { "CRCX_ZYN", CRCX_ZYN, CRCX_ZYN_RET, 97, 126 }, |
Holger Hans Peter Freyther | 0a6455c | 2012-03-16 09:53:49 +0100 | [diff] [blame] | 400 | { "EMPTY", EMPTY, EMPTY_RET }, |
| 401 | { "SHORT1", SHORT, SHORT_RET }, |
| 402 | { "SHORT2", SHORT2, SHORT2_RET }, |
| 403 | { "SHORT3", SHORT3, SHORT2_RET }, |
| 404 | { "SHORT4", SHORT4, SHORT2_RET }, |
Holger Hans Peter Freyther | cd25695 | 2012-12-07 15:04:07 +0100 | [diff] [blame] | 405 | { "RQNT1", RQNT, RQNT1_RET }, |
| 406 | { "RQNT2", RQNT2, RQNT2_RET }, |
Jacob Erlbeck | fe9896f | 2013-11-29 13:43:45 +0100 | [diff] [blame] | 407 | { "DLCX", DLCX, DLCX_RET, -1, -1 }, |
Jacob Erlbeck | ce00725 | 2014-06-12 12:28:12 +0200 | [diff] [blame] | 408 | { "CRCX", CRCX, CRCX_FMTP_RET, 97, 126, .extra_fmtp = "a=fmtp:126 0/1/2" }, |
| 409 | { "MDCX3", MDCX3, MDCX3_FMTP_RET, PTYPE_NONE, 126 , .extra_fmtp = "a=fmtp:126 0/1/2" }, |
| 410 | { "DLCX", DLCX, DLCX_RET, -1, -1 , .extra_fmtp = "a=fmtp:126 0/1/2" }, |
Holger Hans Peter Freyther | cd25695 | 2012-12-07 15:04:07 +0100 | [diff] [blame] | 411 | }; |
| 412 | |
| 413 | static const struct mgcp_test retransmit[] = { |
| 414 | { "CRCX", CRCX, CRCX_RET }, |
| 415 | { "RQNT1", RQNT, RQNT1_RET }, |
| 416 | { "RQNT2", RQNT2, RQNT2_RET }, |
| 417 | { "MDCX3", MDCX3, MDCX3_RET }, |
Holger Hans Peter Freyther | 8fc6d08 | 2012-09-14 17:18:12 +0200 | [diff] [blame] | 418 | { "DLCX", DLCX, DLCX_RET }, |
Harald Welte | a7c9a92 | 2012-01-27 00:36:56 +0100 | [diff] [blame] | 419 | }; |
Harald Welte | 834f3f1 | 2012-01-27 00:00:44 +0100 | [diff] [blame] | 420 | |
| 421 | static struct msgb *create_msg(const char *str) |
Holger Hans Peter Freyther | f0bc075 | 2011-01-06 19:32:52 +0100 | [diff] [blame] | 422 | { |
| 423 | struct msgb *msg; |
| 424 | |
| 425 | msg = msgb_alloc_headroom(4096, 128, "MGCP msg"); |
Holger Hans Peter Freyther | 0f3fa90 | 2013-12-12 13:06:57 +0100 | [diff] [blame] | 426 | int len = sprintf((char *)msg->data, "%s", str); |
Holger Hans Peter Freyther | f0bc075 | 2011-01-06 19:32:52 +0100 | [diff] [blame] | 427 | msg->l2h = msgb_put(msg, len); |
| 428 | return msg; |
| 429 | } |
| 430 | |
Jacob Erlbeck | fe9896f | 2013-11-29 13:43:45 +0100 | [diff] [blame] | 431 | static int last_endpoint = -1; |
| 432 | |
| 433 | static int mgcp_test_policy_cb(struct mgcp_trunk_config *cfg, int endpoint, |
| 434 | int state, const char *transactio_id) |
| 435 | { |
| 436 | fprintf(stderr, "Policy CB got state %d on endpoint %d\n", |
| 437 | state, endpoint); |
| 438 | last_endpoint = endpoint; |
| 439 | return MGCP_POLICY_CONT; |
| 440 | } |
| 441 | |
Jacob Erlbeck | acd8d52 | 2014-01-07 11:38:22 +0100 | [diff] [blame] | 442 | #define MGCP_DUMMY_LOAD 0x23 |
| 443 | static int dummy_packets = 0; |
| 444 | /* override and forward */ |
| 445 | ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, |
| 446 | const struct sockaddr *dest_addr, socklen_t addrlen) |
| 447 | { |
| 448 | typedef ssize_t (*sendto_t)(int, const void *, size_t, int, |
| 449 | const struct sockaddr *, socklen_t); |
| 450 | static sendto_t real_sendto = NULL; |
| 451 | uint32_t dest_host = htonl(((struct sockaddr_in *)dest_addr)->sin_addr.s_addr); |
| 452 | int dest_port = htons(((struct sockaddr_in *)dest_addr)->sin_port); |
| 453 | |
| 454 | if (!real_sendto) |
| 455 | real_sendto = dlsym(RTLD_NEXT, "sendto"); |
| 456 | |
| 457 | if (len == 1 && ((const char *)buf)[0] == MGCP_DUMMY_LOAD ) { |
Holger Hans Peter Freyther | 559d773 | 2014-02-03 09:18:51 +0100 | [diff] [blame] | 458 | fprintf(stderr, "Dummy packet to 0x%08x:%d, msg length %zu\n%s\n\n", |
Jacob Erlbeck | acd8d52 | 2014-01-07 11:38:22 +0100 | [diff] [blame] | 459 | dest_host, dest_port, |
| 460 | len, osmo_hexdump(buf, len)); |
| 461 | dummy_packets += 1; |
| 462 | } |
| 463 | |
| 464 | return real_sendto(sockfd, buf, len, flags, dest_addr, addrlen); |
| 465 | } |
| 466 | |
Jacob Erlbeck | 49677bd | 2014-01-30 21:01:33 +0100 | [diff] [blame] | 467 | static int64_t force_monotonic_time_us = -1; |
| 468 | /* override and forward */ |
| 469 | int clock_gettime(clockid_t clk_id, struct timespec *tp) |
| 470 | { |
| 471 | typedef int (*clock_gettime_t)(clockid_t clk_id, struct timespec *tp); |
| 472 | static clock_gettime_t real_clock_gettime = NULL; |
| 473 | |
| 474 | if (!real_clock_gettime) |
| 475 | real_clock_gettime = dlsym(RTLD_NEXT, "clock_gettime"); |
| 476 | |
| 477 | if (clk_id == CLOCK_MONOTONIC && force_monotonic_time_us >= 0) { |
| 478 | tp->tv_sec = force_monotonic_time_us / 1000000; |
| 479 | tp->tv_nsec = (force_monotonic_time_us % 1000000) * 1000; |
| 480 | return 0; |
| 481 | } |
| 482 | |
| 483 | return real_clock_gettime(clk_id, tp); |
| 484 | } |
| 485 | |
Jacob Erlbeck | f318861 | 2014-01-16 16:50:40 +0100 | [diff] [blame] | 486 | #define CONN_UNMODIFIED (0x1000) |
| 487 | |
| 488 | static void test_values(void) |
| 489 | { |
| 490 | /* Check that NONE disables all output */ |
| 491 | OSMO_ASSERT((MGCP_CONN_NONE & MGCP_CONN_RECV_SEND) == 0) |
| 492 | |
| 493 | /* Check that LOOPBACK enables all output */ |
| 494 | OSMO_ASSERT((MGCP_CONN_LOOPBACK & MGCP_CONN_RECV_SEND) == |
| 495 | MGCP_CONN_RECV_SEND) |
| 496 | } |
| 497 | |
| 498 | |
Holger Hans Peter Freyther | 06ce839 | 2012-03-16 09:45:13 +0100 | [diff] [blame] | 499 | static void test_messages(void) |
Holger Hans Peter Freyther | f0bc075 | 2011-01-06 19:32:52 +0100 | [diff] [blame] | 500 | { |
Holger Hans Peter Freyther | 38484aa | 2012-01-06 15:04:43 +0100 | [diff] [blame] | 501 | struct mgcp_config *cfg; |
Jacob Erlbeck | fe9896f | 2013-11-29 13:43:45 +0100 | [diff] [blame] | 502 | struct mgcp_endpoint *endp; |
Harald Welte | a7c9a92 | 2012-01-27 00:36:56 +0100 | [diff] [blame] | 503 | int i; |
Holger Hans Peter Freyther | 38484aa | 2012-01-06 15:04:43 +0100 | [diff] [blame] | 504 | |
| 505 | cfg = mgcp_config_alloc(); |
Harald Welte | a7c9a92 | 2012-01-27 00:36:56 +0100 | [diff] [blame] | 506 | |
Holger Hans Peter Freyther | ab56ce1 | 2011-02-28 00:56:17 +0100 | [diff] [blame] | 507 | cfg->trunk.number_endpoints = 64; |
Holger Hans Peter Freyther | 49e170b | 2011-02-28 14:37:03 +0100 | [diff] [blame] | 508 | mgcp_endpoints_allocate(&cfg->trunk); |
| 509 | |
Jacob Erlbeck | fe9896f | 2013-11-29 13:43:45 +0100 | [diff] [blame] | 510 | cfg->policy_cb = mgcp_test_policy_cb; |
| 511 | |
Holger Hans Peter Freyther | 49e170b | 2011-02-28 14:37:03 +0100 | [diff] [blame] | 512 | mgcp_endpoints_allocate(mgcp_trunk_alloc(cfg, 1)); |
Holger Hans Peter Freyther | f0bc075 | 2011-01-06 19:32:52 +0100 | [diff] [blame] | 513 | |
Jacob Erlbeck | fe9896f | 2013-11-29 13:43:45 +0100 | [diff] [blame] | 514 | /* reset endpoints */ |
| 515 | for (i = 0; i < cfg->trunk.number_endpoints; i++) { |
| 516 | endp = &cfg->trunk.endpoints[i]; |
Holger Hans Peter Freyther | 4046126 | 2014-09-01 10:35:55 +0200 | [diff] [blame] | 517 | endp->net_end.codec.payload_type = PTYPE_NONE; |
Jacob Erlbeck | 07a25f7 | 2013-12-10 13:09:37 +0100 | [diff] [blame] | 518 | endp->net_end.packet_duration_ms = -1; |
Jacob Erlbeck | f318861 | 2014-01-16 16:50:40 +0100 | [diff] [blame] | 519 | |
| 520 | OSMO_ASSERT(endp->conn_mode == MGCP_CONN_NONE); |
| 521 | endp->conn_mode |= CONN_UNMODIFIED; |
Jacob Erlbeck | fe9896f | 2013-11-29 13:43:45 +0100 | [diff] [blame] | 522 | } |
| 523 | |
Harald Welte | a7c9a92 | 2012-01-27 00:36:56 +0100 | [diff] [blame] | 524 | for (i = 0; i < ARRAY_SIZE(tests); i++) { |
| 525 | const struct mgcp_test *t = &tests[i]; |
| 526 | struct msgb *inp; |
| 527 | struct msgb *msg; |
Holger Hans Peter Freyther | f0bc075 | 2011-01-06 19:32:52 +0100 | [diff] [blame] | 528 | |
Harald Welte | a7c9a92 | 2012-01-27 00:36:56 +0100 | [diff] [blame] | 529 | printf("Testing %s\n", t->name); |
| 530 | |
Jacob Erlbeck | fe9896f | 2013-11-29 13:43:45 +0100 | [diff] [blame] | 531 | last_endpoint = -1; |
Jacob Erlbeck | acd8d52 | 2014-01-07 11:38:22 +0100 | [diff] [blame] | 532 | dummy_packets = 0; |
Jacob Erlbeck | fe9896f | 2013-11-29 13:43:45 +0100 | [diff] [blame] | 533 | |
Jacob Erlbeck | ce00725 | 2014-06-12 12:28:12 +0200 | [diff] [blame] | 534 | bsc_replace_string(cfg, &cfg->trunk.audio_fmtp_extra, t->extra_fmtp); |
| 535 | |
Harald Welte | a7c9a92 | 2012-01-27 00:36:56 +0100 | [diff] [blame] | 536 | inp = create_msg(t->req); |
| 537 | msg = mgcp_handle_message(cfg, inp); |
| 538 | msgb_free(inp); |
Holger Hans Peter Freyther | 0a6455c | 2012-03-16 09:53:49 +0100 | [diff] [blame] | 539 | if (!t->exp_resp) { |
| 540 | if (msg) |
| 541 | printf("%s failed '%s'\n", t->name, (char *) msg->data); |
| 542 | } else if (strcmp((char *) msg->data, t->exp_resp) != 0) |
Harald Welte | a7c9a92 | 2012-01-27 00:36:56 +0100 | [diff] [blame] | 543 | printf("%s failed '%s'\n", t->name, (char *) msg->data); |
| 544 | msgb_free(msg); |
Jacob Erlbeck | fe9896f | 2013-11-29 13:43:45 +0100 | [diff] [blame] | 545 | |
Jacob Erlbeck | acd8d52 | 2014-01-07 11:38:22 +0100 | [diff] [blame] | 546 | if (dummy_packets) |
| 547 | printf("Dummy packets: %d\n", dummy_packets); |
| 548 | |
Jacob Erlbeck | 07a25f7 | 2013-12-10 13:09:37 +0100 | [diff] [blame] | 549 | if (last_endpoint != -1) { |
| 550 | endp = &cfg->trunk.endpoints[last_endpoint]; |
| 551 | |
| 552 | if (endp->net_end.packet_duration_ms != -1) |
| 553 | printf("Detected packet duration: %d\n", |
| 554 | endp->net_end.packet_duration_ms); |
| 555 | else |
| 556 | printf("Packet duration not set\n"); |
Jacob Erlbeck | 91cf743 | 2013-12-09 14:32:03 +0100 | [diff] [blame] | 557 | if (endp->local_options.pkt_period_min || |
| 558 | endp->local_options.pkt_period_max) |
| 559 | printf("Requested packetetization period: " |
| 560 | "%d-%d\n", |
| 561 | endp->local_options.pkt_period_min, |
| 562 | endp->local_options.pkt_period_max); |
| 563 | else |
| 564 | printf("Requested packetization period not set\n"); |
Jacob Erlbeck | 07a25f7 | 2013-12-10 13:09:37 +0100 | [diff] [blame] | 565 | |
Jacob Erlbeck | 4c68c5b | 2014-01-30 21:01:32 +0100 | [diff] [blame] | 566 | if ((endp->conn_mode & CONN_UNMODIFIED) == 0) { |
| 567 | printf("Connection mode: %d:%s%s%s%s\n", |
Jacob Erlbeck | a4cc7cf | 2013-12-19 12:20:49 +0100 | [diff] [blame] | 568 | endp->conn_mode, |
Jacob Erlbeck | 4c68c5b | 2014-01-30 21:01:32 +0100 | [diff] [blame] | 569 | !endp->conn_mode ? " NONE" : "", |
| 570 | endp->conn_mode & MGCP_CONN_SEND_ONLY ? |
| 571 | " SEND" : "", |
| 572 | endp->conn_mode & MGCP_CONN_RECV_ONLY ? |
| 573 | " RECV" : "", |
| 574 | endp->conn_mode & MGCP_CONN_LOOPBACK & |
| 575 | ~MGCP_CONN_RECV_SEND ? |
| 576 | " LOOP" : ""); |
| 577 | fprintf(stderr, |
| 578 | "BTS output %sabled, NET output %sabled\n", |
| 579 | endp->bts_end.output_enabled ? "en" : "dis", |
| 580 | endp->net_end.output_enabled ? "en" : "dis"); |
| 581 | } else |
Jacob Erlbeck | a4cc7cf | 2013-12-19 12:20:49 +0100 | [diff] [blame] | 582 | printf("Connection mode not set\n"); |
| 583 | |
Jacob Erlbeck | f318861 | 2014-01-16 16:50:40 +0100 | [diff] [blame] | 584 | OSMO_ASSERT(endp->net_end.output_enabled == |
| 585 | (endp->conn_mode & MGCP_CONN_SEND_ONLY ? 1 : 0)); |
| 586 | OSMO_ASSERT(endp->bts_end.output_enabled == |
| 587 | (endp->conn_mode & MGCP_CONN_RECV_ONLY ? 1 : 0)); |
| 588 | |
Jacob Erlbeck | 07a25f7 | 2013-12-10 13:09:37 +0100 | [diff] [blame] | 589 | endp->net_end.packet_duration_ms = -1; |
Jacob Erlbeck | d97bcd3 | 2013-12-19 17:01:24 +0100 | [diff] [blame] | 590 | endp->local_options.pkt_period_min = 0; |
| 591 | endp->local_options.pkt_period_max = 0; |
Jacob Erlbeck | 18819c2 | 2014-01-16 16:50:41 +0100 | [diff] [blame] | 592 | endp->conn_mode |= CONN_UNMODIFIED; |
Jacob Erlbeck | 07a25f7 | 2013-12-10 13:09:37 +0100 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | |
Jacob Erlbeck | fe9896f | 2013-11-29 13:43:45 +0100 | [diff] [blame] | 596 | /* Check detected payload type */ |
| 597 | if (t->exp_net_ptype != PTYPE_IGNORE || |
| 598 | t->exp_bts_ptype != PTYPE_IGNORE) { |
| 599 | OSMO_ASSERT(last_endpoint != -1); |
| 600 | endp = &cfg->trunk.endpoints[last_endpoint]; |
| 601 | |
| 602 | fprintf(stderr, "endpoint %d: " |
| 603 | "payload type BTS %d (exp %d), NET %d (exp %d)\n", |
| 604 | last_endpoint, |
Holger Hans Peter Freyther | 4046126 | 2014-09-01 10:35:55 +0200 | [diff] [blame] | 605 | endp->bts_end.codec.payload_type, t->exp_bts_ptype, |
| 606 | endp->net_end.codec.payload_type, t->exp_net_ptype); |
Jacob Erlbeck | fe9896f | 2013-11-29 13:43:45 +0100 | [diff] [blame] | 607 | |
| 608 | if (t->exp_bts_ptype != PTYPE_IGNORE) |
Holger Hans Peter Freyther | 4046126 | 2014-09-01 10:35:55 +0200 | [diff] [blame] | 609 | OSMO_ASSERT(endp->bts_end.codec.payload_type == |
Jacob Erlbeck | fe9896f | 2013-11-29 13:43:45 +0100 | [diff] [blame] | 610 | t->exp_bts_ptype); |
| 611 | if (t->exp_net_ptype != PTYPE_IGNORE) |
Holger Hans Peter Freyther | 4046126 | 2014-09-01 10:35:55 +0200 | [diff] [blame] | 612 | OSMO_ASSERT(endp->net_end.codec.payload_type == |
Jacob Erlbeck | fe9896f | 2013-11-29 13:43:45 +0100 | [diff] [blame] | 613 | t->exp_net_ptype); |
| 614 | |
| 615 | /* Reset them again for next test */ |
Holger Hans Peter Freyther | 4046126 | 2014-09-01 10:35:55 +0200 | [diff] [blame] | 616 | endp->net_end.codec.payload_type = PTYPE_NONE; |
Jacob Erlbeck | fe9896f | 2013-11-29 13:43:45 +0100 | [diff] [blame] | 617 | } |
Harald Welte | a7c9a92 | 2012-01-27 00:36:56 +0100 | [diff] [blame] | 618 | } |
Holger Hans Peter Freyther | f0bc075 | 2011-01-06 19:32:52 +0100 | [diff] [blame] | 619 | |
| 620 | talloc_free(cfg); |
| 621 | } |
| 622 | |
Holger Hans Peter Freyther | cd25695 | 2012-12-07 15:04:07 +0100 | [diff] [blame] | 623 | static void test_retransmission(void) |
| 624 | { |
| 625 | struct mgcp_config *cfg; |
| 626 | int i; |
| 627 | |
| 628 | cfg = mgcp_config_alloc(); |
| 629 | |
| 630 | cfg->trunk.number_endpoints = 64; |
| 631 | mgcp_endpoints_allocate(&cfg->trunk); |
| 632 | |
| 633 | mgcp_endpoints_allocate(mgcp_trunk_alloc(cfg, 1)); |
| 634 | |
Jacob Erlbeck | e91324d | 2013-12-10 13:09:37 +0100 | [diff] [blame] | 635 | /* reset endpoints */ |
| 636 | for (i = 0; i < cfg->trunk.number_endpoints; i++) { |
| 637 | struct mgcp_endpoint *endp; |
| 638 | endp = &cfg->trunk.endpoints[i]; |
| 639 | endp->bts_end.packet_duration_ms = 20; |
| 640 | } |
| 641 | |
Holger Hans Peter Freyther | cd25695 | 2012-12-07 15:04:07 +0100 | [diff] [blame] | 642 | for (i = 0; i < ARRAY_SIZE(retransmit); i++) { |
| 643 | const struct mgcp_test *t = &retransmit[i]; |
| 644 | struct msgb *inp; |
| 645 | struct msgb *msg; |
| 646 | |
| 647 | printf("Testing %s\n", t->name); |
| 648 | |
| 649 | inp = create_msg(t->req); |
| 650 | msg = mgcp_handle_message(cfg, inp); |
| 651 | msgb_free(inp); |
| 652 | if (strcmp((char *) msg->data, t->exp_resp) != 0) |
| 653 | printf("%s failed '%s'\n", t->name, (char *) msg->data); |
| 654 | msgb_free(msg); |
| 655 | |
| 656 | /* Retransmit... */ |
| 657 | printf("Re-transmitting %s\n", t->name); |
| 658 | inp = create_msg(t->req); |
| 659 | msg = mgcp_handle_message(cfg, inp); |
| 660 | msgb_free(inp); |
| 661 | if (strcmp((char *) msg->data, t->exp_resp) != 0) |
| 662 | printf("%s failed '%s'\n", t->name, (char *) msg->data); |
| 663 | msgb_free(msg); |
| 664 | } |
| 665 | |
| 666 | talloc_free(cfg); |
| 667 | } |
| 668 | |
| 669 | static int rqnt_cb(struct mgcp_endpoint *endp, char _tone) |
Holger Hans Peter Freyther | 46880c2 | 2012-11-29 12:54:22 +0100 | [diff] [blame] | 670 | { |
| 671 | ptrdiff_t tone = _tone; |
| 672 | endp->cfg->data = (void *) tone; |
| 673 | return 0; |
| 674 | } |
| 675 | |
| 676 | static void test_rqnt_cb(void) |
| 677 | { |
| 678 | struct mgcp_config *cfg; |
| 679 | struct msgb *inp, *msg; |
| 680 | |
| 681 | cfg = mgcp_config_alloc(); |
| 682 | cfg->rqnt_cb = rqnt_cb; |
| 683 | |
| 684 | cfg->trunk.number_endpoints = 64; |
| 685 | mgcp_endpoints_allocate(&cfg->trunk); |
| 686 | |
| 687 | mgcp_endpoints_allocate(mgcp_trunk_alloc(cfg, 1)); |
| 688 | |
| 689 | inp = create_msg(CRCX); |
| 690 | msgb_free(mgcp_handle_message(cfg, inp)); |
| 691 | msgb_free(inp); |
| 692 | |
| 693 | /* send the RQNT and check for the CB */ |
| 694 | inp = create_msg(RQNT); |
| 695 | msg = mgcp_handle_message(cfg, inp); |
| 696 | if (strncmp((const char *) msg->l2h, "200", 3) != 0) { |
| 697 | printf("FAILED: message is not 200. '%s'\n", msg->l2h); |
| 698 | abort(); |
| 699 | } |
| 700 | |
| 701 | if (cfg->data != (void *) '9') { |
| 702 | printf("FAILED: callback not called: %p\n", cfg->data); |
| 703 | abort(); |
| 704 | } |
| 705 | |
| 706 | msgb_free(msg); |
| 707 | msgb_free(inp); |
| 708 | |
| 709 | inp = create_msg(DLCX); |
| 710 | msgb_free(mgcp_handle_message(cfg, inp)); |
| 711 | msgb_free(inp); |
| 712 | talloc_free(cfg); |
| 713 | } |
| 714 | |
Holger Hans Peter Freyther | faa6793 | 2012-10-22 18:09:35 +0200 | [diff] [blame] | 715 | struct pl_test { |
| 716 | int cycles; |
| 717 | uint16_t base_seq; |
| 718 | uint16_t max_seq; |
| 719 | uint32_t packets; |
| 720 | |
| 721 | uint32_t expected; |
| 722 | int loss; |
| 723 | }; |
| 724 | |
| 725 | static const struct pl_test pl_test_dat[] = { |
| 726 | /* basic.. just one package */ |
| 727 | { .cycles = 0, .base_seq = 0, .max_seq = 0, .packets = 1, .expected = 1, .loss = 0}, |
| 728 | /* some packages and a bit of loss */ |
| 729 | { .cycles = 0, .base_seq = 0, .max_seq = 100, .packets = 100, .expected = 101, .loss = 1}, |
| 730 | /* wrap around */ |
| 731 | { .cycles = 1<<16, .base_seq = 0xffff, .max_seq = 2, .packets = 4, .expected = 4, .loss = 0}, |
| 732 | /* min loss */ |
| 733 | { .cycles = 0, .base_seq = 0, .max_seq = 0, .packets = UINT_MAX, .expected = 1, .loss = INT_MIN }, |
| 734 | /* max loss, with wrap around on expected max */ |
| 735 | { .cycles = INT_MAX, .base_seq = 0, .max_seq = UINT16_MAX, .packets = 0, .expected = ((uint32_t)(INT_MAX) + UINT16_MAX + 1), .loss = INT_MAX }, |
| 736 | }; |
| 737 | |
| 738 | static void test_packet_loss_calc(void) |
| 739 | { |
| 740 | int i; |
| 741 | printf("Testing packet loss calculation.\n"); |
| 742 | |
| 743 | for (i = 0; i < ARRAY_SIZE(pl_test_dat); ++i) { |
| 744 | uint32_t expected; |
| 745 | int loss; |
| 746 | struct mgcp_rtp_state state; |
| 747 | struct mgcp_rtp_end rtp; |
| 748 | memset(&state, 0, sizeof(state)); |
| 749 | memset(&rtp, 0, sizeof(rtp)); |
| 750 | |
Holger Hans Peter Freyther | 0c67169 | 2014-10-06 20:04:42 +0200 | [diff] [blame] | 751 | state.stats_initialized = 1; |
| 752 | state.stats_base_seq = pl_test_dat[i].base_seq; |
| 753 | state.stats_max_seq = pl_test_dat[i].max_seq; |
| 754 | state.stats_cycles = pl_test_dat[i].cycles; |
Holger Hans Peter Freyther | faa6793 | 2012-10-22 18:09:35 +0200 | [diff] [blame] | 755 | |
| 756 | rtp.packets = pl_test_dat[i].packets; |
| 757 | mgcp_state_calc_loss(&state, &rtp, &expected, &loss); |
| 758 | |
| 759 | if (loss != pl_test_dat[i].loss || expected != pl_test_dat[i].expected) { |
| 760 | printf("FAIL: Wrong exp/loss at idx(%d) Loss(%d vs. %d) Exp(%u vs. %u)\n", |
| 761 | i, loss, pl_test_dat[i].loss, |
| 762 | expected, pl_test_dat[i].expected); |
| 763 | } |
| 764 | } |
| 765 | } |
| 766 | |
Holger Hans Peter Freyther | 931d698 | 2012-10-24 21:53:40 +0200 | [diff] [blame] | 767 | static void test_mgcp_stats(void) |
| 768 | { |
| 769 | printf("Testing stat parsing\n"); |
| 770 | |
| 771 | uint32_t bps, bos, pr, _or, jitter; |
| 772 | struct msgb *msg; |
| 773 | int loss; |
| 774 | int rc; |
| 775 | |
| 776 | msg = create_msg(DLCX_RET); |
| 777 | rc = mgcp_parse_stats(msg, &bps, &bos, &pr, &_or, &loss, &jitter); |
| 778 | printf("Parsing result: %d\n", rc); |
| 779 | if (bps != 0 || bos != 0 || pr != 0 || _or != 0 || loss != 0 || jitter != 0) |
| 780 | printf("FAIL: Parsing failed1.\n"); |
| 781 | msgb_free(msg); |
| 782 | |
| 783 | msg = create_msg("250 7 OK\r\nP: PS=10, OS=20, PR=30, OR=40, PL=-3, JI=40\r\n"); |
| 784 | rc = mgcp_parse_stats(msg, &bps, &bos, &pr, &_or, &loss, &jitter); |
| 785 | printf("Parsing result: %d\n", rc); |
| 786 | if (bps != 10 || bos != 20 || pr != 30 || _or != 40 || loss != -3 || jitter != 40) |
| 787 | printf("FAIL: Parsing failed2.\n"); |
| 788 | msgb_free(msg); |
| 789 | } |
| 790 | |
Jacob Erlbeck | 4516a8a | 2013-11-25 12:53:29 +0100 | [diff] [blame] | 791 | struct rtp_packet_info { |
| 792 | float txtime; |
| 793 | int len; |
| 794 | char *data; |
| 795 | }; |
| 796 | |
| 797 | struct rtp_packet_info test_rtp_packets1[] = { |
| 798 | /* RTP: SeqNo=0, TS=0 */ |
| 799 | {0.000000, 20, "\x80\x62\x00\x00\x00\x00\x00\x00\x11\x22\x33\x44" |
| 800 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 801 | /* RTP: SeqNo=1, TS=160 */ |
| 802 | {0.020000, 20, "\x80\x62\x00\x01\x00\x00\x00\xA0\x11\x22\x33\x44" |
| 803 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 804 | /* RTP: SeqNo=2, TS=320 */ |
| 805 | {0.040000, 20, "\x80\x62\x00\x02\x00\x00\x01\x40\x11\x22\x33\x44" |
| 806 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 807 | /* Repeat RTP timestamp: */ |
| 808 | /* RTP: SeqNo=3, TS=320 */ |
| 809 | {0.060000, 20, "\x80\x62\x00\x03\x00\x00\x01\x40\x11\x22\x33\x44" |
| 810 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 811 | /* RTP: SeqNo=4, TS=480 */ |
| 812 | {0.080000, 20, "\x80\x62\x00\x04\x00\x00\x01\xE0\x11\x22\x33\x44" |
| 813 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 814 | /* RTP: SeqNo=5, TS=640 */ |
| 815 | {0.100000, 20, "\x80\x62\x00\x05\x00\x00\x02\x80\x11\x22\x33\x44" |
| 816 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 817 | /* Double skip RTP timestamp (delta = 2*160): */ |
| 818 | /* RTP: SeqNo=6, TS=960 */ |
| 819 | {0.120000, 20, "\x80\x62\x00\x06\x00\x00\x03\xC0\x11\x22\x33\x44" |
| 820 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 821 | /* RTP: SeqNo=7, TS=1120 */ |
| 822 | {0.140000, 20, "\x80\x62\x00\x07\x00\x00\x04\x60\x11\x22\x33\x44" |
| 823 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 824 | /* RTP: SeqNo=8, TS=1280 */ |
| 825 | {0.160000, 20, "\x80\x62\x00\x08\x00\x00\x05\x00\x11\x22\x33\x44" |
| 826 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 827 | /* Non 20ms RTP timestamp (delta = 120): */ |
| 828 | /* RTP: SeqNo=9, TS=1400 */ |
| 829 | {0.180000, 20, "\x80\x62\x00\x09\x00\x00\x05\x78\x11\x22\x33\x44" |
| 830 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 831 | /* RTP: SeqNo=10, TS=1560 */ |
| 832 | {0.200000, 20, "\x80\x62\x00\x0A\x00\x00\x06\x18\x11\x22\x33\x44" |
| 833 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 834 | /* RTP: SeqNo=11, TS=1720 */ |
| 835 | {0.220000, 20, "\x80\x62\x00\x0B\x00\x00\x06\xB8\x11\x22\x33\x44" |
| 836 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 837 | /* SSRC changed to 0x10203040, RTP timestamp jump */ |
| 838 | /* RTP: SeqNo=12, TS=34688 */ |
| 839 | {0.240000, 20, "\x80\x62\x00\x0C\x00\x00\x87\x80\x10\x20\x30\x40" |
| 840 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 841 | /* RTP: SeqNo=13, TS=34848 */ |
| 842 | {0.260000, 20, "\x80\x62\x00\x0D\x00\x00\x88\x20\x10\x20\x30\x40" |
| 843 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 844 | /* RTP: SeqNo=14, TS=35008 */ |
| 845 | {0.280000, 20, "\x80\x62\x00\x0E\x00\x00\x88\xC0\x10\x20\x30\x40" |
| 846 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
Jacob Erlbeck | eb19f55 | 2013-12-03 12:48:07 +0100 | [diff] [blame] | 847 | /* Non 20ms RTP timestamp (delta = 120): */ |
| 848 | /* RTP: SeqNo=15, TS=35128 */ |
| 849 | {0.300000, 20, "\x80\x62\x00\x0F\x00\x00\x89\x38\x10\x20\x30\x40" |
| 850 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 851 | /* RTP: SeqNo=16, TS=35288 */ |
| 852 | {0.320000, 20, "\x80\x62\x00\x10\x00\x00\x89\xD8\x10\x20\x30\x40" |
| 853 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 854 | /* RTP: SeqNo=17, TS=35448 */ |
| 855 | {0.340000, 20, "\x80\x62\x00\x11\x00\x00\x8A\x78\x10\x20\x30\x40" |
| 856 | "\x01\x23\x45\x67\x8A\xAB\xCD\xEF"}, |
| 857 | /* SeqNo increment by 2, RTP timestamp delta = 320: */ |
| 858 | /* RTP: SeqNo=19, TS=35768 */ |
| 859 | {0.360000, 20, "\x80\x62\x00\x13\x00\x00\x8B\xB8\x10\x20\x30\x40" |
| 860 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 861 | /* RTP: SeqNo=20, TS=35928 */ |
| 862 | {0.380000, 20, "\x80\x62\x00\x14\x00\x00\x8C\x58\x10\x20\x30\x40" |
| 863 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 864 | /* RTP: SeqNo=21, TS=36088 */ |
Jacob Erlbeck | 1e9b28b | 2013-12-18 12:54:49 +0100 | [diff] [blame] | 865 | {0.380000, 20, "\x80\x62\x00\x15\x00\x00\x8C\xF8\x10\x20\x30\x40" |
| 866 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 867 | /* Repeat last packet */ |
| 868 | /* RTP: SeqNo=21, TS=36088 */ |
| 869 | {0.400000, 20, "\x80\x62\x00\x15\x00\x00\x8C\xF8\x10\x20\x30\x40" |
| 870 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 871 | /* RTP: SeqNo=22, TS=36248 */ |
| 872 | {0.420000, 20, "\x80\x62\x00\x16\x00\x00\x8D\x98\x10\x20\x30\x40" |
| 873 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 874 | /* RTP: SeqNo=23, TS=36408 */ |
| 875 | {0.440000, 20, "\x80\x62\x00\x17\x00\x00\x8E\x38\x10\x20\x30\x40" |
| 876 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 877 | /* Don't increment SeqNo but increment timestamp by 160 */ |
| 878 | /* RTP: SeqNo=23, TS=36568 */ |
| 879 | {0.460000, 20, "\x80\x62\x00\x17\x00\x00\x8E\xD8\x10\x20\x30\x40" |
| 880 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 881 | /* RTP: SeqNo=24, TS=36728 */ |
| 882 | {0.480000, 20, "\x80\x62\x00\x18\x00\x00\x8F\x78\x10\x20\x30\x40" |
| 883 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 884 | /* RTP: SeqNo=25, TS=36888 */ |
| 885 | {0.500000, 20, "\x80\x62\x00\x19\x00\x00\x90\x18\x10\x20\x30\x40" |
Jacob Erlbeck | eb19f55 | 2013-12-03 12:48:07 +0100 | [diff] [blame] | 886 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
Jacob Erlbeck | 49677bd | 2014-01-30 21:01:33 +0100 | [diff] [blame] | 887 | /* SSRC changed to 0x50607080, RTP timestamp jump, Delay of 1.5s, |
| 888 | * SeqNo jump */ |
| 889 | /* RTP: SeqNo=1000, TS=160000 */ |
| 890 | {2.000000, 20, "\x80\x62\x03\xE8\x00\x02\x71\x00\x50\x60\x70\x80" |
| 891 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 892 | /* RTP: SeqNo=1001, TS=160160 */ |
| 893 | {2.020000, 20, "\x80\x62\x03\xE9\x00\x02\x71\xA0\x50\x60\x70\x80" |
| 894 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
| 895 | /* RTP: SeqNo=1002, TS=160320 */ |
| 896 | {2.040000, 20, "\x80\x62\x03\xEA\x00\x02\x72\x40\x50\x60\x70\x80" |
| 897 | "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, |
Jacob Erlbeck | 4516a8a | 2013-11-25 12:53:29 +0100 | [diff] [blame] | 898 | }; |
| 899 | |
| 900 | void mgcp_patch_and_count(struct mgcp_endpoint *endp, struct mgcp_rtp_state *state, |
| 901 | struct mgcp_rtp_end *rtp_end, struct sockaddr_in *addr, |
| 902 | char *data, int len); |
| 903 | |
Jacob Erlbeck | eb19f55 | 2013-12-03 12:48:07 +0100 | [diff] [blame] | 904 | static void test_packet_error_detection(int patch_ssrc, int patch_ts) |
Jacob Erlbeck | 4516a8a | 2013-11-25 12:53:29 +0100 | [diff] [blame] | 905 | { |
| 906 | int i; |
| 907 | |
| 908 | struct mgcp_trunk_config trunk; |
| 909 | struct mgcp_endpoint endp; |
| 910 | struct mgcp_rtp_state state; |
Jacob Erlbeck | ac9f6ce | 2013-11-25 15:23:35 +0100 | [diff] [blame] | 911 | struct mgcp_rtp_end *rtp = &endp.net_end; |
Jacob Erlbeck | 4516a8a | 2013-11-25 12:53:29 +0100 | [diff] [blame] | 912 | struct sockaddr_in addr = {0}; |
| 913 | char buffer[4096]; |
Jacob Erlbeck | eb19f55 | 2013-12-03 12:48:07 +0100 | [diff] [blame] | 914 | uint32_t last_ssrc = 0; |
Jacob Erlbeck | 888fec6 | 2013-12-18 12:54:50 +0100 | [diff] [blame] | 915 | uint32_t last_timestamp = 0; |
| 916 | uint32_t last_seqno = 0; |
| 917 | int last_in_ts_err_cnt = 0; |
| 918 | int last_out_ts_err_cnt = 0; |
Jacob Erlbeck | 4516a8a | 2013-11-25 12:53:29 +0100 | [diff] [blame] | 919 | |
Jacob Erlbeck | eb19f55 | 2013-12-03 12:48:07 +0100 | [diff] [blame] | 920 | printf("Testing packet error detection%s%s.\n", |
| 921 | patch_ssrc ? ", patch SSRC" : "", |
| 922 | patch_ts ? ", patch timestamps" : ""); |
Jacob Erlbeck | 4516a8a | 2013-11-25 12:53:29 +0100 | [diff] [blame] | 923 | |
| 924 | memset(&trunk, 0, sizeof(trunk)); |
| 925 | memset(&endp, 0, sizeof(endp)); |
| 926 | memset(&state, 0, sizeof(state)); |
Jacob Erlbeck | 4516a8a | 2013-11-25 12:53:29 +0100 | [diff] [blame] | 927 | |
| 928 | trunk.number_endpoints = 1; |
| 929 | trunk.endpoints = &endp; |
Jacob Erlbeck | e5546cd | 2013-12-03 14:43:34 +0100 | [diff] [blame] | 930 | trunk.force_constant_ssrc = patch_ssrc; |
Jacob Erlbeck | f12c849 | 2013-12-18 12:54:51 +0100 | [diff] [blame] | 931 | trunk.force_aligned_timing = patch_ts; |
Jacob Erlbeck | e5546cd | 2013-12-03 14:43:34 +0100 | [diff] [blame] | 932 | |
Jacob Erlbeck | 4516a8a | 2013-11-25 12:53:29 +0100 | [diff] [blame] | 933 | endp.tcfg = &trunk; |
| 934 | |
Holger Hans Peter Freyther | bb8627a | 2014-07-22 15:00:52 +0200 | [diff] [blame] | 935 | mgcp_initialize_endp(&endp); |
Jacob Erlbeck | ac9f6ce | 2013-11-25 15:23:35 +0100 | [diff] [blame] | 936 | |
Holger Hans Peter Freyther | 4046126 | 2014-09-01 10:35:55 +0200 | [diff] [blame] | 937 | rtp->codec.payload_type = 98; |
Jacob Erlbeck | ac9f6ce | 2013-11-25 15:23:35 +0100 | [diff] [blame] | 938 | |
Jacob Erlbeck | 4516a8a | 2013-11-25 12:53:29 +0100 | [diff] [blame] | 939 | for (i = 0; i < ARRAY_SIZE(test_rtp_packets1); ++i) { |
| 940 | struct rtp_packet_info *info = test_rtp_packets1 + i; |
| 941 | |
Holger Hans Peter Freyther | e5d57f6 | 2014-02-03 13:25:42 +0100 | [diff] [blame] | 942 | force_monotonic_time_us = round(1000000.0 * info->txtime); |
Jacob Erlbeck | 49677bd | 2014-01-30 21:01:33 +0100 | [diff] [blame] | 943 | |
Jacob Erlbeck | 4516a8a | 2013-11-25 12:53:29 +0100 | [diff] [blame] | 944 | OSMO_ASSERT(info->len <= sizeof(buffer)); |
| 945 | OSMO_ASSERT(info->len >= 0); |
| 946 | memmove(buffer, info->data, info->len); |
| 947 | |
Jacob Erlbeck | e5546cd | 2013-12-03 14:43:34 +0100 | [diff] [blame] | 948 | mgcp_rtp_end_config(&endp, 1, rtp); |
| 949 | |
Jacob Erlbeck | ac9f6ce | 2013-11-25 15:23:35 +0100 | [diff] [blame] | 950 | mgcp_patch_and_count(&endp, &state, rtp, &addr, |
Jacob Erlbeck | 4516a8a | 2013-11-25 12:53:29 +0100 | [diff] [blame] | 951 | buffer, info->len); |
| 952 | |
Jacob Erlbeck | eb19f55 | 2013-12-03 12:48:07 +0100 | [diff] [blame] | 953 | if (state.out_stream.ssrc != last_ssrc) { |
| 954 | printf("Output SSRC changed to %08x\n", |
Jacob Erlbeck | 866a76d | 2013-12-03 15:47:04 +0100 | [diff] [blame] | 955 | state.out_stream.ssrc); |
Jacob Erlbeck | eb19f55 | 2013-12-03 12:48:07 +0100 | [diff] [blame] | 956 | last_ssrc = state.out_stream.ssrc; |
| 957 | } |
| 958 | |
Jacob Erlbeck | 888fec6 | 2013-12-18 12:54:50 +0100 | [diff] [blame] | 959 | printf("In TS: %d, dTS: %d, Seq: %d\n", |
| 960 | state.in_stream.last_timestamp, |
| 961 | state.in_stream.last_tsdelta, |
| 962 | state.in_stream.last_seq); |
| 963 | |
| 964 | printf("Out TS change: %d, dTS: %d, Seq change: %d, " |
| 965 | "TS Err change: in %+d, out %+d\n", |
| 966 | state.out_stream.last_timestamp - last_timestamp, |
Jacob Erlbeck | 4516a8a | 2013-11-25 12:53:29 +0100 | [diff] [blame] | 967 | state.out_stream.last_tsdelta, |
Jacob Erlbeck | 888fec6 | 2013-12-18 12:54:50 +0100 | [diff] [blame] | 968 | state.out_stream.last_seq - last_seqno, |
| 969 | state.in_stream.err_ts_counter - last_in_ts_err_cnt, |
| 970 | state.out_stream.err_ts_counter - last_out_ts_err_cnt); |
| 971 | |
Holger Hans Peter Freyther | 4d6874f | 2014-02-03 09:20:06 +0100 | [diff] [blame] | 972 | printf("Stats: Jitter = %u, Transit = %d\n", |
Holger Hans Peter Freyther | 0c67169 | 2014-10-06 20:04:42 +0200 | [diff] [blame] | 973 | mgcp_state_calc_jitter(&state), state.stats_transit); |
Jacob Erlbeck | 49677bd | 2014-01-30 21:01:33 +0100 | [diff] [blame] | 974 | |
Jacob Erlbeck | 888fec6 | 2013-12-18 12:54:50 +0100 | [diff] [blame] | 975 | last_in_ts_err_cnt = state.in_stream.err_ts_counter; |
| 976 | last_out_ts_err_cnt = state.out_stream.err_ts_counter; |
| 977 | last_timestamp = state.out_stream.last_timestamp; |
| 978 | last_seqno = state.out_stream.last_seq; |
Jacob Erlbeck | 4516a8a | 2013-11-25 12:53:29 +0100 | [diff] [blame] | 979 | } |
Jacob Erlbeck | 49677bd | 2014-01-30 21:01:33 +0100 | [diff] [blame] | 980 | |
| 981 | force_monotonic_time_us = -1; |
Jacob Erlbeck | 4516a8a | 2013-11-25 12:53:29 +0100 | [diff] [blame] | 982 | } |
| 983 | |
Holger Hans Peter Freyther | 171817c | 2014-09-01 10:50:22 +0200 | [diff] [blame] | 984 | static void test_multilple_codec(void) |
| 985 | { |
| 986 | struct mgcp_config *cfg; |
| 987 | struct mgcp_endpoint *endp; |
| 988 | struct msgb *inp, *resp; |
Holger Hans Peter Freyther | a0a8e45 | 2015-08-17 15:50:01 +0200 | [diff] [blame] | 989 | struct in_addr addr; |
Holger Hans Peter Freyther | 171817c | 2014-09-01 10:50:22 +0200 | [diff] [blame] | 990 | |
| 991 | printf("Testing multiple payload types\n"); |
| 992 | |
| 993 | cfg = mgcp_config_alloc(); |
| 994 | cfg->trunk.number_endpoints = 64; |
| 995 | mgcp_endpoints_allocate(&cfg->trunk); |
| 996 | cfg->policy_cb = mgcp_test_policy_cb; |
| 997 | mgcp_endpoints_allocate(mgcp_trunk_alloc(cfg, 1)); |
| 998 | |
| 999 | /* Allocate endpoint 1@mgw with two codecs */ |
| 1000 | last_endpoint = -1; |
| 1001 | inp = create_msg(CRCX_MULT_1); |
| 1002 | resp = mgcp_handle_message(cfg, inp); |
| 1003 | msgb_free(inp); |
| 1004 | msgb_free(resp); |
| 1005 | |
| 1006 | OSMO_ASSERT(last_endpoint == 1); |
| 1007 | endp = &cfg->trunk.endpoints[last_endpoint]; |
| 1008 | OSMO_ASSERT(endp->net_end.codec.payload_type == 18); |
| 1009 | OSMO_ASSERT(endp->net_end.alt_codec.payload_type == 97); |
| 1010 | |
| 1011 | /* Allocate 2@mgw with three codecs, last one ignored */ |
| 1012 | last_endpoint = -1; |
| 1013 | inp = create_msg(CRCX_MULT_2); |
| 1014 | resp = mgcp_handle_message(cfg, inp); |
| 1015 | msgb_free(inp); |
| 1016 | msgb_free(resp); |
| 1017 | |
| 1018 | OSMO_ASSERT(last_endpoint == 2); |
| 1019 | endp = &cfg->trunk.endpoints[last_endpoint]; |
| 1020 | OSMO_ASSERT(endp->net_end.codec.payload_type == 18); |
| 1021 | OSMO_ASSERT(endp->net_end.alt_codec.payload_type == 97); |
| 1022 | |
| 1023 | /* Allocate 3@mgw with no codecs, check for PT == -1 */ |
| 1024 | last_endpoint = -1; |
| 1025 | inp = create_msg(CRCX_MULT_3); |
| 1026 | resp = mgcp_handle_message(cfg, inp); |
| 1027 | msgb_free(inp); |
| 1028 | msgb_free(resp); |
| 1029 | |
| 1030 | OSMO_ASSERT(last_endpoint == 3); |
| 1031 | endp = &cfg->trunk.endpoints[last_endpoint]; |
| 1032 | OSMO_ASSERT(endp->net_end.codec.payload_type == -1); |
| 1033 | OSMO_ASSERT(endp->net_end.alt_codec.payload_type == -1); |
| 1034 | |
| 1035 | /* Allocate 4@mgw with a single codec */ |
| 1036 | last_endpoint = -1; |
| 1037 | inp = create_msg(CRCX_MULT_4); |
| 1038 | resp = mgcp_handle_message(cfg, inp); |
| 1039 | msgb_free(inp); |
| 1040 | msgb_free(resp); |
| 1041 | |
| 1042 | OSMO_ASSERT(last_endpoint == 4); |
| 1043 | endp = &cfg->trunk.endpoints[last_endpoint]; |
| 1044 | OSMO_ASSERT(endp->net_end.codec.payload_type == 18); |
| 1045 | OSMO_ASSERT(endp->net_end.alt_codec.payload_type == -1); |
| 1046 | |
Holger Hans Peter Freyther | ac27e82 | 2015-08-14 15:43:06 +0200 | [diff] [blame] | 1047 | /* Allocate 5@mgw at select GSM.. */ |
| 1048 | last_endpoint = -1; |
| 1049 | inp = create_msg(CRCX_MULT_GSM_EXACT); |
| 1050 | talloc_free(cfg->trunk.audio_name); |
| 1051 | cfg->trunk.audio_name = "GSM/8000"; |
| 1052 | cfg->trunk.no_audio_transcoding = 1; |
| 1053 | resp = mgcp_handle_message(cfg, inp); |
| 1054 | msgb_free(inp); |
| 1055 | msgb_free(resp); |
| 1056 | |
| 1057 | OSMO_ASSERT(last_endpoint == 5); |
| 1058 | endp = &cfg->trunk.endpoints[last_endpoint]; |
| 1059 | OSMO_ASSERT(endp->net_end.codec.payload_type == 3); |
| 1060 | OSMO_ASSERT(endp->net_end.alt_codec.payload_type == -1); |
| 1061 | |
Holger Hans Peter Freyther | a0a8e45 | 2015-08-17 15:50:01 +0200 | [diff] [blame] | 1062 | inp = create_msg(MDCX_NAT_DUMMY); |
| 1063 | last_endpoint = -1; |
| 1064 | resp = mgcp_handle_message(cfg, inp); |
| 1065 | msgb_free(inp); |
| 1066 | msgb_free(resp); |
| 1067 | OSMO_ASSERT(last_endpoint == 5); |
| 1068 | endp = &cfg->trunk.endpoints[last_endpoint]; |
| 1069 | OSMO_ASSERT(endp->net_end.codec.payload_type == 3); |
| 1070 | OSMO_ASSERT(endp->net_end.alt_codec.payload_type == -1); |
| 1071 | OSMO_ASSERT(endp->net_end.rtp_port == htons(16434)); |
| 1072 | memset(&addr, 0, sizeof(addr)); |
| 1073 | inet_aton("8.8.8.8", &addr); |
| 1074 | OSMO_ASSERT(endp->net_end.addr.s_addr == addr.s_addr); |
| 1075 | |
Holger Hans Peter Freyther | ac27e82 | 2015-08-14 15:43:06 +0200 | [diff] [blame] | 1076 | /* Check what happens without that flag */ |
| 1077 | |
| 1078 | /* Free the previous endpoint and the data ... */ |
| 1079 | mgcp_release_endp(endp); |
| 1080 | talloc_free(endp->last_response); |
| 1081 | talloc_free(endp->last_trans); |
| 1082 | endp->last_response = endp->last_trans = NULL; |
| 1083 | |
| 1084 | last_endpoint = -1; |
| 1085 | inp = create_msg(CRCX_MULT_GSM_EXACT); |
| 1086 | cfg->trunk.no_audio_transcoding = 0; |
| 1087 | resp = mgcp_handle_message(cfg, inp); |
| 1088 | msgb_free(inp); |
| 1089 | msgb_free(resp); |
| 1090 | |
| 1091 | OSMO_ASSERT(last_endpoint == 5); |
| 1092 | endp = &cfg->trunk.endpoints[last_endpoint]; |
Holger Hans Peter Freyther | a267b33 | 2015-08-17 15:19:57 +0200 | [diff] [blame] | 1093 | OSMO_ASSERT(endp->net_end.codec.payload_type == 255); |
| 1094 | OSMO_ASSERT(endp->net_end.alt_codec.payload_type == 0); |
Holger Hans Peter Freyther | 171817c | 2014-09-01 10:50:22 +0200 | [diff] [blame] | 1095 | |
| 1096 | talloc_free(cfg); |
| 1097 | } |
| 1098 | |
Holger Hans Peter Freyther | 10c8968 | 2014-10-06 21:01:26 +0200 | [diff] [blame] | 1099 | static void test_no_cycle(void) |
| 1100 | { |
| 1101 | struct mgcp_config *cfg; |
| 1102 | struct mgcp_endpoint *endp; |
| 1103 | |
| 1104 | printf("Testing no sequence flow on initial packet\n"); |
| 1105 | |
| 1106 | cfg = mgcp_config_alloc(); |
| 1107 | cfg->trunk.number_endpoints = 64; |
| 1108 | mgcp_endpoints_allocate(&cfg->trunk); |
| 1109 | |
| 1110 | endp = &cfg->trunk.endpoints[1]; |
| 1111 | OSMO_ASSERT(endp->net_state.stats_initialized == 0); |
| 1112 | |
| 1113 | mgcp_rtp_annex_count(endp, &endp->net_state, 0, 0, 2342); |
| 1114 | OSMO_ASSERT(endp->net_state.stats_initialized == 1); |
| 1115 | OSMO_ASSERT(endp->net_state.stats_cycles == 0); |
| 1116 | OSMO_ASSERT(endp->net_state.stats_max_seq == 0); |
| 1117 | |
| 1118 | mgcp_rtp_annex_count(endp, &endp->net_state, 1, 0, 2342); |
| 1119 | OSMO_ASSERT(endp->net_state.stats_initialized == 1); |
| 1120 | OSMO_ASSERT(endp->net_state.stats_cycles == 0); |
| 1121 | OSMO_ASSERT(endp->net_state.stats_max_seq == 1); |
| 1122 | |
| 1123 | /* now jump.. */ |
| 1124 | mgcp_rtp_annex_count(endp, &endp->net_state, UINT16_MAX, 0, 2342); |
| 1125 | OSMO_ASSERT(endp->net_state.stats_initialized == 1); |
| 1126 | OSMO_ASSERT(endp->net_state.stats_cycles == 0); |
| 1127 | OSMO_ASSERT(endp->net_state.stats_max_seq == UINT16_MAX); |
| 1128 | |
| 1129 | /* and wrap */ |
| 1130 | mgcp_rtp_annex_count(endp, &endp->net_state, 0, 0, 2342); |
| 1131 | OSMO_ASSERT(endp->net_state.stats_initialized == 1); |
| 1132 | OSMO_ASSERT(endp->net_state.stats_cycles == UINT16_MAX + 1); |
| 1133 | OSMO_ASSERT(endp->net_state.stats_max_seq == 0); |
| 1134 | |
| 1135 | talloc_free(cfg); |
| 1136 | } |
| 1137 | |
Holger Hans Peter Freyther | 60e0992 | 2014-11-19 16:04:45 +0100 | [diff] [blame] | 1138 | static void test_no_name(void) |
| 1139 | { |
| 1140 | struct mgcp_config *cfg; |
| 1141 | struct mgcp_endpoint *endp; |
| 1142 | struct msgb *inp, *msg; |
| 1143 | int i; |
| 1144 | |
| 1145 | printf("Testing no rtpmap name\n"); |
| 1146 | cfg = mgcp_config_alloc(); |
| 1147 | |
| 1148 | cfg->trunk.number_endpoints = 64; |
| 1149 | cfg->trunk.audio_send_name = 0; |
| 1150 | mgcp_endpoints_allocate(&cfg->trunk); |
| 1151 | |
| 1152 | cfg->policy_cb = mgcp_test_policy_cb; |
| 1153 | |
| 1154 | mgcp_endpoints_allocate(mgcp_trunk_alloc(cfg, 1)); |
| 1155 | |
| 1156 | /* reset endpoints */ |
| 1157 | for (i = 0; i < cfg->trunk.number_endpoints; i++) { |
| 1158 | endp = &cfg->trunk.endpoints[i]; |
| 1159 | endp->net_end.codec.payload_type = PTYPE_NONE; |
| 1160 | endp->net_end.packet_duration_ms = -1; |
| 1161 | |
| 1162 | OSMO_ASSERT(endp->conn_mode == MGCP_CONN_NONE); |
| 1163 | endp->conn_mode |= CONN_UNMODIFIED; |
| 1164 | } |
| 1165 | |
| 1166 | inp = create_msg(CRCX); |
| 1167 | msg = mgcp_handle_message(cfg, inp); |
| 1168 | if (strcmp((char *) msg->data, CRCX_RET_NO_RTPMAP) != 0) |
| 1169 | printf("FAILED: there should not be a RTPMAP: %s\n", |
| 1170 | (char *) msg->data); |
| 1171 | msgb_free(inp); |
| 1172 | msgb_free(msg); |
| 1173 | |
| 1174 | mgcp_release_endp(&cfg->trunk.endpoints[1]); |
| 1175 | talloc_free(cfg); |
| 1176 | } |
| 1177 | |
Holger Hans Peter Freyther | b95dd2c | 2015-10-02 15:56:35 +0200 | [diff] [blame] | 1178 | static void test_osmux_cid(void) |
| 1179 | { |
| 1180 | int id, i; |
| 1181 | |
| 1182 | OSMO_ASSERT(osmux_used_cid() == 0); |
| 1183 | id = osmux_get_cid(); |
| 1184 | OSMO_ASSERT(id == 0); |
| 1185 | OSMO_ASSERT(osmux_used_cid() == 1); |
| 1186 | osmux_put_cid(id); |
| 1187 | OSMO_ASSERT(osmux_used_cid() == 0); |
| 1188 | |
Holger Hans Peter Freyther | 60f85a7 | 2015-10-02 16:11:15 +0200 | [diff] [blame^] | 1189 | for (i = 0; i < 128; ++i) { |
Holger Hans Peter Freyther | b95dd2c | 2015-10-02 15:56:35 +0200 | [diff] [blame] | 1190 | id = osmux_get_cid(); |
| 1191 | OSMO_ASSERT(id == i); |
| 1192 | OSMO_ASSERT(osmux_used_cid() == i + 1); |
| 1193 | } |
| 1194 | |
| 1195 | id = osmux_get_cid(); |
| 1196 | OSMO_ASSERT(id == -1); |
| 1197 | |
| 1198 | for (i = 0; i < 256; ++i) |
| 1199 | osmux_put_cid(i); |
| 1200 | OSMO_ASSERT(osmux_used_cid() == 0); |
| 1201 | } |
| 1202 | |
Holger Hans Peter Freyther | f0bc075 | 2011-01-06 19:32:52 +0100 | [diff] [blame] | 1203 | int main(int argc, char **argv) |
| 1204 | { |
Holger Hans Peter Freyther | 2d59cc6 | 2011-05-12 16:02:07 +0200 | [diff] [blame] | 1205 | osmo_init_logging(&log_info); |
Holger Hans Peter Freyther | f0bc075 | 2011-01-06 19:32:52 +0100 | [diff] [blame] | 1206 | |
Jacob Erlbeck | e7060c4 | 2013-11-29 13:43:44 +0100 | [diff] [blame] | 1207 | test_strline(); |
Jacob Erlbeck | f318861 | 2014-01-16 16:50:40 +0100 | [diff] [blame] | 1208 | test_values(); |
Holger Hans Peter Freyther | 06ce839 | 2012-03-16 09:45:13 +0100 | [diff] [blame] | 1209 | test_messages(); |
Holger Hans Peter Freyther | cd25695 | 2012-12-07 15:04:07 +0100 | [diff] [blame] | 1210 | test_retransmission(); |
Holger Hans Peter Freyther | faa6793 | 2012-10-22 18:09:35 +0200 | [diff] [blame] | 1211 | test_packet_loss_calc(); |
Holger Hans Peter Freyther | 46880c2 | 2012-11-29 12:54:22 +0100 | [diff] [blame] | 1212 | test_rqnt_cb(); |
Holger Hans Peter Freyther | 931d698 | 2012-10-24 21:53:40 +0200 | [diff] [blame] | 1213 | test_mgcp_stats(); |
Jacob Erlbeck | eb19f55 | 2013-12-03 12:48:07 +0100 | [diff] [blame] | 1214 | test_packet_error_detection(1, 0); |
| 1215 | test_packet_error_detection(0, 0); |
| 1216 | test_packet_error_detection(0, 1); |
| 1217 | test_packet_error_detection(1, 1); |
Holger Hans Peter Freyther | 171817c | 2014-09-01 10:50:22 +0200 | [diff] [blame] | 1218 | test_multilple_codec(); |
Holger Hans Peter Freyther | 10c8968 | 2014-10-06 21:01:26 +0200 | [diff] [blame] | 1219 | test_no_cycle(); |
Holger Hans Peter Freyther | 60e0992 | 2014-11-19 16:04:45 +0100 | [diff] [blame] | 1220 | test_no_name(); |
Holger Hans Peter Freyther | b95dd2c | 2015-10-02 15:56:35 +0200 | [diff] [blame] | 1221 | test_osmux_cid(); |
Holger Hans Peter Freyther | 38484aa | 2012-01-06 15:04:43 +0100 | [diff] [blame] | 1222 | |
| 1223 | printf("Done\n"); |
| 1224 | return EXIT_SUCCESS; |
Holger Hans Peter Freyther | f0bc075 | 2011-01-06 19:32:52 +0100 | [diff] [blame] | 1225 | } |