blob: 1abb63b0102ad69b2323987441237d4e768a4dae [file] [log] [blame]
Holger Hans Peter Freythera7328a52013-07-13 17:09:56 +02001/*
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 Hofmeyr90843962017-09-04 15:04:35 +020023#include <osmocom/msc/debug.h>
Holger Hans Peter Freythera7328a52013-07-13 17:09:56 +020024
25#include <osmocom/core/application.h>
26#include <osmocom/core/backtrace.h>
27
28#include "smpp_smsc.h"
29
30struct coding_test {
31 uint8_t dcs;
32 uint8_t coding;
33 int mode;
34 int res;
35};
36
37static 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
47static 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 Hofmeyr6a8b9c72018-03-22 15:51:22 +010065static 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
73const 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 Freythera7328a52013-07-13 17:09:56 +020078int main(int argc, char **argv)
79{
Neels Hofmeyr08b38282018-03-30 23:04:04 +020080 void *ctx = talloc_named_const(NULL, 0, "smpp_test");
81 osmo_init_logging2(ctx, &log_info);
Holger Hans Peter Freythera7328a52013-07-13 17:09:56 +020082 log_set_use_color(osmo_stderr_target, 0);
83 log_set_print_filename(osmo_stderr_target, 0);
84
85 test_coding_scheme();
86 return EXIT_SUCCESS;
87}