9
0
Fork 0

bss patching: Add test cases for assignment and assignment complete patching

* Chosen Channel and Speech Version are both optional. Patch them
  separately if they are present.
* Add testcase for the assignment request patching.
This commit is contained in:
Holger Hans Peter Freyther 2013-03-25 10:00:18 +01:00
parent 6cd4e9521d
commit 63bb411522
3 changed files with 61 additions and 12 deletions

View File

@ -80,22 +80,22 @@ static void patch_ass_cmpl(struct msgb *msg, int length)
}
tlv_parse(&tp, gsm0808_att_tlvdef(), msg->l3h + 1, length - 1, 0, 0);
if (!TLVP_PRESENT(&tp, GSM0808_IE_CHOSEN_CHANNEL)) {
/* Now patch chosen channel and speech version */
if (TLVP_PRESENT(&tp, GSM0808_IE_CHOSEN_CHANNEL)) {
data = (uint8_t *) TLVP_VAL(&tp, GSM0808_IE_CHOSEN_CHANNEL);
data[0] = 0x09;
} else {
LOGP(DMSC, LOGL_ERROR, "Chosen Channel not in the MSG.\n");
return;
}
if (!TLVP_PRESENT(&tp, GSM0808_IE_SPEECH_VERSION)) {
if (TLVP_PRESENT(&tp, GSM0808_IE_SPEECH_VERSION)) {
data = (uint8_t *) TLVP_VAL(&tp, GSM0808_IE_SPEECH_VERSION);
data[0] = GSM0808_PERM_HR3;
} else {
LOGP(DMSC, LOGL_ERROR, "Speech version not in the MSG.\n");
return;
}
/* claim to have a TCH/H with no mode indication */
data = (uint8_t *) TLVP_VAL(&tp, GSM0808_IE_CHOSEN_CHANNEL);
data[0] = 0x09;
data = (uint8_t *) TLVP_VAL(&tp, GSM0808_IE_SPEECH_VERSION);
data[0] = GSM0808_PERM_HR3;
}
int bss_patch_filter_msg(struct msgb *msg, struct sccp_parse_result *sccp, int dir)

View File

@ -3,6 +3,7 @@ noinst_PROGRAMS = patching_test
EXTRA_DIST = patching_test.ok
patching_test_SOURCES = patching_test.c $(top_srcdir)/src/bss_patch.c
patching_test_SOURCES = patching_test.c $(top_srcdir)/src/bss_patch.c \
$(top_srcdir)/src/debug.c
patching_test_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOSCCP_LIBS) $(LIBOSMOGSM_LIBS)

View File

@ -2,6 +2,7 @@
#include <cellmgr_debug.h>
#include <osmocom/core/application.h>
#include <osmocom/core/utils.h>
#include <stdio.h>
@ -35,6 +36,18 @@ static const uint8_t cc[] = {
0x02, 0x01, 0x04,
0x00, 0x01, 0x01, 0xb4, 0x02, 0x01, 0x00 };
static const uint8_t ass_rewrite[] = {
0x06, 0xe5, 0xe2, 0x0e, 0x00, 0x01, 0x0c, 0x00,
0x0a, 0x01, 0x0b, 0x04, 0x01, 0x0b, 0xa1, 0x25,
0x01, 0x00, 0x08
};
static const uint8_t ass_rewrite_patched[] = {
0x06, 0xe5, 0xe2, 0x0e, 0x00, 0x01, 0x0c, 0x00,
0x0a, 0x01, 0x0b, 0x04, 0x01, 0x0a, 0x91, 0x25,
0x01, 0x00, 0x08
};
struct result {
const uint8_t *input;
@ -75,6 +88,12 @@ static struct result results[] = {
.exp_len = sizeof(cc),
.result = 0,
},
{
.input = ass_rewrite,
.inp_len = sizeof(ass_rewrite),
.expected = ass_rewrite_patched,
.exp_len = sizeof(ass_rewrite_patched),
},
};
static const uint8_t udt_with_poi[] = {
@ -135,6 +154,21 @@ static const uint8_t dt1_cc_setup[] = {
0x99, 0x13, 0x28, 0x77, 0x77
};
static const uint8_t dt1_ass_compl_norewrite[] = {
0x06, 0x01, 0x09, 0xaf, 0x00, 0x01, 0x09, 0x00,
0x07, 0x02, 0x21, 0x09, 0x2c, 0x02, 0x40, 0x25,
};
static const uint8_t dt1_ass_compl[] = {
0x06, 0x01, 0x02, 0x47, 0x00, 0x01, 0x05, 0x00,
0x03, 0x02, 0x40, 0x01,
};
static const uint8_t dt1_ass_compl_patched[] = {
0x06, 0x01, 0x02, 0x47, 0x00, 0x01, 0x05, 0x00,
0x03, 0x02, 0x40, 0x25,
};
static struct result rewrite_results_to_msc[] = {
{
.input = udt_with_poi,
@ -170,6 +204,18 @@ static struct result rewrite_results_to_msc[] = {
.expected = dt1_cc_setup,
.exp_len = sizeof(dt1_cc_setup),
},
{
.input = dt1_ass_compl_norewrite,
.inp_len = sizeof(dt1_ass_compl_norewrite),
.expected = dt1_ass_compl_norewrite,
.exp_len = sizeof(dt1_ass_compl_norewrite),
},
{
.input = dt1_ass_compl,
.inp_len = sizeof(dt1_ass_compl),
.expected = dt1_ass_compl_patched,
.exp_len = sizeof(dt1_ass_compl_patched),
},
};
@ -304,6 +350,8 @@ static void test_rewrite_bsc(void)
int main(int argc, char **argv)
{
osmo_init_logging(&log_info);
test_patch_filter();
test_rewrite_msc();
test_rewrite_bsc();