Exemple #1
0
int gprs_gb_parse_llc(uint8_t *llc, size_t llc_len,
		      struct gprs_gb_parse_context *parse_ctx)
{
	struct gprs_llc_hdr_parsed *ghp = &parse_ctx->llc_hdr_parsed;
	int rc;
	int fcs;

	/* parse LLC */
	rc = gprs_llc_hdr_parse(ghp, llc, llc_len);
	gprs_llc_hdr_dump(ghp);
	if (rc != 0) {
		LOGP(DLLC, LOGL_NOTICE, "Error during LLC header parsing\n");
		return 0;
	}

	fcs = gprs_llc_fcs(llc, ghp->crc_length);
	LOGP(DLLC, LOGL_DEBUG, "Got LLC message, CRC: %06x (computed %06x)\n",
	     ghp->fcs, fcs);

	if (!ghp->data)
		return 0;

	if (ghp->sapi != GPRS_SAPI_GMM)
		return 1;

	if (ghp->cmd != GPRS_LLC_UI)
		return 1;

	if (ghp->is_encrypted) {
		parse_ctx->need_decryption = 1;
		return 0;
	}

	return gprs_gb_parse_dtap(ghp->data, ghp->data_len, parse_ctx);
}
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 == 6) {
		printf("GPRS attach with increasing N(U) done.\n");
		gprs_test_success(pcu);
	}
}