mirror of https://gerrit.osmocom.org/libosmocore
add gsm0341_test to generate SMSCB hex strings
Those hex strings can then be copy+pasted into the OSmoNITB VTY
This commit is contained in:
parent
a19717a7c5
commit
783d073a37
|
@ -52,6 +52,7 @@ nobase_include_HEADERS = \
|
|||
osmocom/gsm/comp128.h \
|
||||
osmocom/gsm/comp128v23.h \
|
||||
osmocom/gsm/gan.h \
|
||||
osmocom/gsm/gsm0341.h \
|
||||
osmocom/gsm/gsm0411_smc.h \
|
||||
osmocom/gsm/gsm0411_smr.h \
|
||||
osmocom/gsm/gsm0411_utils.h \
|
||||
|
|
|
@ -20,7 +20,7 @@ libosmogsm_la_SOURCES = a5.c rxlev_stat.c tlv_parser.c comp128.c comp128v23.c \
|
|||
auth_core.c auth_comp128v1.c auth_comp128v23.c \
|
||||
auth_milenage.c milenage/aes-encblock.c \
|
||||
milenage/aes-internal.c milenage/aes-internal-enc.c \
|
||||
milenage/milenage.c gan.c ipa.c
|
||||
milenage/milenage.c gan.c ipa.c gsm0341.c
|
||||
|
||||
libosmogsm_la_LDFLAGS = $(LTLDFLAGS_OSMOGSM) -version-info $(LIBVERSION) -no-undefined
|
||||
libosmogsm_la_LIBADD = $(top_builddir)/src/libosmocore.la
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* (C) 2014 by Harald Welte <laforge@gnumonks.org>
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <osmocom/core/talloc.h>
|
||||
#include <osmocom/gsm/protocol/gsm_03_41.h>
|
||||
|
||||
struct gsm341_ms_message *
|
||||
gsm0341_build_msg(void *ctx, uint8_t geo_scope, uint8_t msg_code,
|
||||
uint8_t update, uint16_t msg_id, uint8_t dcs,
|
||||
uint8_t page_total, uint8_t page_cur,
|
||||
uint8_t *data, uint8_t len)
|
||||
{
|
||||
struct gsm341_ms_message *cbmsg;
|
||||
|
||||
if (len > 88)
|
||||
return NULL;
|
||||
|
||||
cbmsg = talloc_zero_size(ctx, sizeof(*cbmsg)+len);
|
||||
if (!cbmsg)
|
||||
return NULL;
|
||||
|
||||
cbmsg->serial.code_hi = (msg_code >> 4) & 0xF;
|
||||
cbmsg->serial.gs = geo_scope;
|
||||
cbmsg->serial.update = update;
|
||||
cbmsg->serial.code_lo = msg_code & 0xF;
|
||||
cbmsg->msg_id = msg_id;
|
||||
cbmsg->dcs.group = dcs >> 4;
|
||||
cbmsg->dcs.language = dcs & 0xF;
|
||||
cbmsg->page.total = page_total;
|
||||
cbmsg->page.current = page_cur;
|
||||
memcpy(cbmsg->data, data, len);
|
||||
|
||||
return cbmsg;
|
||||
}
|
|
@ -38,6 +38,8 @@ gprs_cipher_supported;
|
|||
gprs_tlli_type;
|
||||
gprs_tmsi2tlli;
|
||||
|
||||
gsm0341_build_msg;
|
||||
|
||||
gsm0480_create_notifySS;
|
||||
gsm0480_create_unstructuredSS_Notify;
|
||||
gsm0480_create_ussd_resp;
|
||||
|
|
|
@ -8,7 +8,8 @@ check_PROGRAMS = timer/timer_test sms/sms_test ussd/ussd_test \
|
|||
gb/bssgp_fc_test gb/gprs_bssgp_test gb/gprs_ns_test \
|
||||
kasumi/kasumi_test logging/logging_test fr/fr_test \
|
||||
loggingrb/loggingrb_test strrb/strrb_test \
|
||||
vty/vty_test comp128/comp128_test utils/utils_test
|
||||
vty/vty_test comp128/comp128_test utils/utils_test \
|
||||
smscb/gsm0341_test
|
||||
|
||||
if ENABLE_MSGFILE
|
||||
check_PROGRAMS += msgfile/msgfile_test
|
||||
|
@ -50,6 +51,9 @@ msgfile_msgfile_test_LDADD = $(top_builddir)/src/libosmocore.la
|
|||
smscb_smscb_test_SOURCES = smscb/smscb_test.c
|
||||
smscb_smscb_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la
|
||||
|
||||
smscb_gsm0341_test_SOURCES = smscb/gsm0341_test.c
|
||||
smscb_gsm0341_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la
|
||||
|
||||
sms_sms_test_SOURCES = sms/sms_test.c
|
||||
sms_sms_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la
|
||||
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* (C) 2014 by Harald Welte <laforge@gnumonks.org>
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <osmocom/gsm/protocol/gsm_03_41.h>
|
||||
#include <osmocom/gsm/gsm0341.h>
|
||||
#include <osmocom/gsm/gsm_utils.h>
|
||||
#include <osmocom/core/utils.h>
|
||||
#include <osmocom/core/msgb.h>
|
||||
|
||||
struct gsm341_ms_message *gen_msg_from_text(uint16_t msg_id, const char *text)
|
||||
{
|
||||
struct gsm341_ms_message *cbmsg;
|
||||
int text_len = strlen(text);
|
||||
/* assuming default GSM alphabet, the encoded payload cannot be
|
||||
* longer than the input text */
|
||||
uint8_t payload[text_len];
|
||||
int payload_octets;
|
||||
|
||||
gsm_7bit_encode_n(payload, sizeof(payload), text, &payload_octets);
|
||||
cbmsg = gsm0341_build_msg(NULL, 0, 23, 0, msg_id, 0xf0, 1, 1, payload, payload_octets);
|
||||
|
||||
printf("%s\n", osmo_hexdump_nospc((uint8_t *)cbmsg, sizeof(*cbmsg)+payload_octets));
|
||||
|
||||
return cbmsg;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
uint16_t msg_id = GSM341_MSGID_ETWS_CMAS_MONTHLY_TEST;
|
||||
char *text = "Mahlzeit!";
|
||||
|
||||
if (argc > 1)
|
||||
msg_id = atoi(argv[1]);
|
||||
|
||||
if (argc > 2)
|
||||
text = argv[2];
|
||||
|
||||
gen_msg_from_text(msg_id, text);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Loading…
Reference in New Issue