コード例 #1
0
static inline void test_get(struct bitvec *bv, unsigned n)
{
	bitvec_to_string_r(bv, lol);
	printf("%s [%d]", lol, bv->cur_bit);
	int16_t x = bitvec_get_int16_msb(bv, n);
	uint8_t tmp[2];
	osmo_store16be(x, &tmp);
	printf(" -> %d (%u bit) ["OSMO_BIN_SPEC" "OSMO_BIN_SPEC"]:\n", x, n, OSMO_BIN_PRINT(tmp[0]), OSMO_BIN_PRINT(tmp[1]));
	bitvec_to_string_r(bv, lol);
	printf("%s [%d]\n", lol, bv->cur_bit);
}
コード例 #2
0
ファイル: gsm29205.c プロジェクト: osmocom/libosmocore
/*! Create Global Call Reference.
 *  \param[out] msg Message Buffer for appending IE
 *  \param[in] g Global Call Reference, 3GPP TS 29.205 Table B 2.1.9.1
 *  \returns number of bytes added to \a msg */
uint8_t osmo_enc_gcr(struct msgb *msg, const struct osmo_gcr_parsed *g)
{
	uint8_t buf[2];

	if (!g)
		return 0;

	if (g->net_len < 3 || g->net_len > 5)
		return 0;

	msgb_lv_put(msg, g->net_len, g->net);

	osmo_store16be(g->node, &buf);
	msgb_lv_put(msg, 2, buf);

	msgb_lv_put(msg, 5, g->cr);

	/* Length: LV(Net) + LV(Node) + LV(CRef) - see 3GPP TS §3.2.2.115 */
	return (g->net_len + 1) + (2 + 1) + (5 + 1);
}