aboutsummaryrefslogtreecommitdiffstats
path: root/tests/emu/test_replay_gprs_attach.cpp
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-08-22 08:44:38 +0200
committerIvan Kluchnikov <kluchnikovi@gmail.com>2013-09-04 21:28:53 +0400
commitbc1e52cfbf89dc9c669281181f99dc5098ea8364 (patch)
treed939d9936e8141d0890a5f77266b103352ac4b19 /tests/emu/test_replay_gprs_attach.cpp
parent741481d3e007f6cc38b3e8d090a49be1caf99b12 (diff)
emu: Use OpenBSC code to decode the LLC and add assertions
Use the OpenBSC SGSN code to parse the LLC data and look into the data we receive. Add assertions to verify the the sequence number is increasing.
Diffstat (limited to 'tests/emu/test_replay_gprs_attach.cpp')
-rw-r--r--tests/emu/test_replay_gprs_attach.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/emu/test_replay_gprs_attach.cpp b/tests/emu/test_replay_gprs_attach.cpp
index 500b16e1..fb1e77f7 100644
--- a/tests/emu/test_replay_gprs_attach.cpp
+++ b/tests/emu/test_replay_gprs_attach.cpp
@@ -19,13 +19,18 @@
extern "C" {
#include <osmocom/core/msgb.h>
+#include <osmocom/core/backtrace.h>
+#include <osmocom/gsm/gsm_utils.h>
}
+#include "openbsc_clone.h"
+
#include <gprs_bssgp_pcu.h>
#include <stdint.h>
#include <string.h>
+/* GPRS attach with a foreign TLLI */
static const uint8_t gprs_attach_llc[] = {
/* LLC-PDU IE */
0x0e, 0x00, 0x2e,
@@ -38,6 +43,8 @@ static const uint8_t gprs_attach_llc[] = {
0x42, 0x00, 0x40, 0xaa, 0xf3, 0x18
};
+static int next_wanted_nu;
+
struct msgb *create_msg(const uint8_t *data, size_t len)
{
struct msgb *msg = msgb_alloc_headroom(4096, 128, "create msg");
@@ -51,6 +58,38 @@ void test_replay_gprs_attach(struct gprs_bssgp_pcu *pcu)
uint32_t tlli = 0xadf11820;
const uint8_t qos_profile[] = { 0x0, 0x0, 0x04 };
+ next_wanted_nu = 0;
struct msgb *msg = create_msg(gprs_attach_llc, ARRAY_SIZE(gprs_attach_llc));
bssgp_tx_ul_ud(pcu->bctx, tlli, qos_profile, msg);
}
+
+void test_replay_gprs_data(struct gprs_bssgp_pcu *pcu, struct msgb *msg, struct tlv_parsed *tp)
+{
+ struct bssgp_ud_hdr *budh;
+ struct gprs_llc_hdr_parsed ph;
+ uint32_t tlli;
+
+ if (!TLVP_PRESENT(tp, BSSGP_IE_LLC_PDU))
+ return;
+
+
+ gprs_llc_hdr_parse(&ph, TLVP_VAL(tp, BSSGP_IE_LLC_PDU),
+ TLVP_LEN(tp, BSSGP_IE_LLC_PDU));
+
+ budh = (struct bssgp_ud_hdr *)msgb_bssgph(msg);
+ tlli = ntohl(budh->tlli);
+
+ /* all messages we should get, should be for a foreign tlli */
+ OSMO_ASSERT(gprs_tlli_type(tlli) == TLLI_FOREIGN);
+ printf("TLLI(0x%08x) is foreign!\n", tlli);
+
+ OSMO_ASSERT(ph.cmd == GPRS_LLC_UI);
+ OSMO_ASSERT(ph.sapi == 1);
+ OSMO_ASSERT(ph.seq_tx == next_wanted_nu++);
+
+ /* this test just wants to see messages... no further data is sent */
+ if (next_wanted_nu == 4) {
+ printf("Test done.\n");
+ exit(EXIT_SUCCESS);
+ }
+}