Holger Hans Peter Freyther | a7328a5 | 2013-07-13 17:09:56 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) 2013 by Holger Hans Peter Freyther |
| 3 | * All Rights Reserved |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU Affero General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU Affero General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Affero General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | * |
| 18 | */ |
| 19 | |
| 20 | #include <stdlib.h> |
| 21 | #include <stdio.h> |
| 22 | |
Neels Hofmeyr | 9084396 | 2017-09-04 15:04:35 +0200 | [diff] [blame] | 23 | #include <osmocom/msc/debug.h> |
Holger Hans Peter Freyther | a7328a5 | 2013-07-13 17:09:56 +0200 | [diff] [blame] | 24 | |
| 25 | #include <osmocom/core/application.h> |
| 26 | #include <osmocom/core/backtrace.h> |
| 27 | |
| 28 | #include "smpp_smsc.h" |
| 29 | |
| 30 | struct coding_test { |
| 31 | uint8_t dcs; |
| 32 | uint8_t coding; |
| 33 | int mode; |
| 34 | int res; |
| 35 | }; |
| 36 | |
| 37 | static struct coding_test codecs[] = { |
| 38 | { .dcs = 0xf6 , .coding = 0x02, .mode = MODE_8BIT, .res = 0 }, |
| 39 | { .dcs = 0xf2 , .coding = 0x01, .mode = MODE_7BIT, .res = 0 }, |
| 40 | { .dcs = 0x02 , .coding = 0x01, .mode = MODE_7BIT, .res = 0 }, |
| 41 | { .dcs = 0x06 , .coding = 0x02, .mode = MODE_8BIT, .res = 0 }, |
| 42 | { .dcs = 0x0A , .coding = 0x08, .mode = MODE_8BIT, .res = 0 }, |
| 43 | { .dcs = 0x0E , .coding = 0xFF, .mode = 0xFF, .res = -1 }, |
| 44 | { .dcs = 0xE0 , .coding = 0xFF, .mode = 0xFF, .res = -1 }, |
| 45 | }; |
| 46 | |
| 47 | static void test_coding_scheme(void) |
| 48 | { |
| 49 | int i; |
| 50 | printf("Testing coding scheme support\n"); |
| 51 | |
| 52 | for (i = 0; i < ARRAY_SIZE(codecs); ++i) { |
| 53 | uint8_t coding; |
| 54 | int mode, res; |
| 55 | |
| 56 | res = smpp_determine_scheme(codecs[i].dcs, &coding, &mode); |
| 57 | OSMO_ASSERT(res == codecs[i].res); |
| 58 | if (res != -1) { |
| 59 | OSMO_ASSERT(mode == codecs[i].mode); |
| 60 | OSMO_ASSERT(coding == codecs[i].coding); |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
Neels Hofmeyr | 6a8b9c7 | 2018-03-22 15:51:22 +0100 | [diff] [blame] | 65 | static const struct log_info_cat smpp_mirror_default_categories[] = { |
| 66 | [DSMPP] = { |
| 67 | .name = "DSMPP", |
| 68 | .description = "SMPP interface for external SMS apps", |
| 69 | .enabled = 1, .loglevel = LOGL_DEBUG, |
| 70 | }, |
| 71 | }; |
| 72 | |
| 73 | const struct log_info log_info = { |
| 74 | .cat = smpp_mirror_default_categories, |
| 75 | .num_cat = ARRAY_SIZE(smpp_mirror_default_categories), |
| 76 | }; |
| 77 | |
Holger Hans Peter Freyther | a7328a5 | 2013-07-13 17:09:56 +0200 | [diff] [blame] | 78 | int main(int argc, char **argv) |
| 79 | { |
Neels Hofmeyr | 08b3828 | 2018-03-30 23:04:04 +0200 | [diff] [blame] | 80 | void *ctx = talloc_named_const(NULL, 0, "smpp_test"); |
| 81 | osmo_init_logging2(ctx, &log_info); |
Holger Hans Peter Freyther | a7328a5 | 2013-07-13 17:09:56 +0200 | [diff] [blame] | 82 | log_set_use_color(osmo_stderr_target, 0); |
Pau Espin Pedrol | cad22fd | 2021-02-19 13:37:00 +0100 | [diff] [blame] | 83 | log_set_print_filename2(osmo_stderr_target, LOG_FILENAME_NONE); |
Pau Espin Pedrol | 8d02d99 | 2021-02-19 13:36:47 +0100 | [diff] [blame] | 84 | log_set_print_category(osmo_stderr_target, 0); |
| 85 | log_set_print_category_hex(osmo_stderr_target, 0); |
Holger Hans Peter Freyther | a7328a5 | 2013-07-13 17:09:56 +0200 | [diff] [blame] | 86 | |
| 87 | test_coding_scheme(); |
| 88 | return EXIT_SUCCESS; |
| 89 | } |