Interesting how reset_last_msg() and bssgp_tx_dl_ud() use the global
last_dl_parse_ctx directly, while get_new_ptmsi() receives it as
argument :)
~Neels
On Mon, Oct 12, 2015 at 07:36:32PM +0200, Daniel Willmann wrote:
unsigned sgsn_tx_counter = 0;
+struct msgb *last_msg = NULL;
+struct gprs_gb_parse_context last_dl_parse_ctx;
+
+static void reset_last_msg()
+{
+ if (last_msg)
+ msgb_free(last_msg);
+
+ last_msg = NULL;
+ memset(&last_dl_parse_ctx, 0, sizeof(last_dl_parse_ctx));
+}
static void cleanup_test()
{
+ reset_last_msg();
+}
+
+static uint32_t get_new_ptmsi(const struct gprs_gb_parse_context *parse_ctx)
+{
+ uint32_t new_ptmsi = GSM_RESERVED_TMSI;
+
+ if (parse_ctx->new_ptmsi_enc)
+ gprs_parse_tmsi(parse_ctx->new_ptmsi_enc, &new_ptmsi);
+
+ return new_ptmsi;
}
/* override */
int bssgp_tx_dl_ud(struct msgb *msg, uint16_t pdu_lifetime,
struct bssgp_dl_ud_par *dup)
{
+ int rc;
+
+ reset_last_msg();
+
+ last_msg = msg;
+ OSMO_ASSERT(msgb_data(last_msg) != NULL);
+
+ rc = gprs_gb_parse_llc(msgb_data(last_msg), msgb_length(last_msg),
+ &last_dl_parse_ctx);
+
+ fprintf(stderr, "Got DL LLC message: %s\n",
+ gprs_gb_message_name(&last_dl_parse_ctx, "UNKNOWN"));
+
+ OSMO_ASSERT(rc > 0);
+
sgsn_tx_counter += 1;
- msgb_free(msg);
return 0;
}