[gsm48] Move gsm48_parse_meas_rep to gsm_04_08_utils

Move the function over to the _utils side as handover
measurement is compiled into libbsc and we don't want
to end up with linking errors.
diff --git a/openbsc/src/gsm_04_08_utils.c b/openbsc/src/gsm_04_08_utils.c
index 2cd571e..2db46ca 100644
--- a/openbsc/src/gsm_04_08_utils.c
+++ b/openbsc/src/gsm_04_08_utils.c
@@ -700,3 +700,72 @@
 		rsl_ipacc_crcx(msg->lchan);
 	return rc;
 }
+
+int gsm48_parse_meas_rep(struct gsm_meas_rep *rep, struct msgb *msg)
+{
+	struct gsm48_hdr *gh = msgb_l3(msg);
+	unsigned int payload_len = msgb_l3len(msg) - sizeof(*gh);
+	u_int8_t *data = gh->data;
+	struct gsm_bts *bts = msg->lchan->ts->trx->bts;
+	struct bitvec *nbv = &bts->si_common.neigh_list;
+
+	if (gh->msg_type != GSM48_MT_RR_MEAS_REP)
+		return -EINVAL;
+
+	if (data[0] & 0x80)
+		rep->flags |= MEAS_REP_F_BA1;
+	if (data[0] & 0x40)
+		rep->flags |= MEAS_REP_F_UL_DTX;
+	if ((data[1] & 0x40) == 0x00)
+		rep->flags |= MEAS_REP_F_DL_VALID;
+
+	rep->dl.full.rx_lev = data[0] & 0x3f;
+	rep->dl.sub.rx_lev = data[1] & 0x3f;
+	rep->dl.full.rx_qual = (data[3] >> 4) & 0x7;
+	rep->dl.sub.rx_qual = (data[3] >> 1) & 0x7;
+
+	rep->num_cell = ((data[3] >> 6) & 0x3) | ((data[2] & 0x01) << 2);
+	if (rep->num_cell < 1 || rep->num_cell > 6)
+		return 0;
+
+	/* an encoding nightmare in perfection */
+
+	rep->cell[0].rxlev = data[3] & 0x3f;
+	rep->cell[0].arfcn = bitvec_get_nth_set_bit(nbv, data[4] >> 2);
+	rep->cell[0].bsic = ((data[4] & 0x07) << 3) | (data[5] >> 5);
+	if (rep->num_cell < 2)
+		return 0;
+
+	rep->cell[1].rxlev = ((data[5] & 0x1f) << 1) | (data[6] >> 7);
+	rep->cell[1].arfcn = bitvec_get_nth_set_bit(nbv, (data[6] >> 2) & 0x1f);
+	rep->cell[1].bsic = ((data[6] & 0x03) << 4) | (data[7] >> 4);
+	if (rep->num_cell < 3)
+		return 0;
+
+	rep->cell[2].rxlev = ((data[7] & 0x0f) << 2) | (data[8] >> 6);
+	rep->cell[2].arfcn = bitvec_get_nth_set_bit(nbv, (data[8] >> 1) & 0x1f);
+	rep->cell[2].bsic = ((data[8] & 0x01) << 6) | (data[9] >> 3);
+	if (rep->num_cell < 4)
+		return 0;
+
+	rep->cell[3].rxlev = ((data[9] & 0x07) << 3) | (data[10] >> 5);
+	rep->cell[3].arfcn = bitvec_get_nth_set_bit(nbv, data[10] & 0x1f);
+	rep->cell[3].bsic = data[11] >> 2;
+	if (rep->num_cell < 5)
+		return 0;
+
+	rep->cell[4].rxlev = ((data[11] & 0x03) << 4) | (data[12] >> 4);
+	rep->cell[4].arfcn = bitvec_get_nth_set_bit(nbv,
+				((data[12] & 0xf) << 1) | (data[13] >> 7));
+	rep->cell[4].bsic = (data[13] >> 1) & 0x3f;
+	if (rep->num_cell < 6)
+		return 0;
+
+	rep->cell[5].rxlev = ((data[13] & 0x01) << 5) | (data[14] >> 3);
+	rep->cell[5].arfcn = bitvec_get_nth_set_bit(nbv,
+				((data[14] & 0x07) << 2) | (data[15] >> 6));
+	rep->cell[5].bsic = data[15] & 0x3f;
+
+	return 0;
+}
+