[openbsc 2/5] sgsn/test: Really parse received DL LLC messages

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Neels Hofmeyr nhofmeyr at sysmocom.de
Tue Oct 13 09:36:33 UTC 2015


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;
>  }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.osmocom.org/pipermail/openbsc/attachments/20151013/3a460ccf/attachment.bin>


More information about the OpenBSC mailing list