[gprs] Build the SGSN stand-alone and not as part of bsc_hack
Instead of continuing to add more and more functionality to the
bsc_hack binary, we should have the new SGSN code run as a separate
executable.
After this commit we now build a 'osmo_sgsn' executable, using its
own osmo_sgsn.cfg config file.
However, the SGSN is not yet functional, mainly due to the fact that
the BSSGP and GMM code are written with the assumption that there
is a msgb->trx->bts and the according 'sturct gsm_bts' data model
around - which clearly is no longer the case outside of bsc_hack.
diff --git a/openbsc/src/gprs_bssgp.c b/openbsc/src/gprs_bssgp.c
index a2181b1..ab6d1a0 100644
--- a/openbsc/src/gprs_bssgp.c
+++ b/openbsc/src/gprs_bssgp.c
@@ -138,6 +138,25 @@
return gprs_ns_sendmsg(bssgp_nsi, msg);
}
+/* Chapter 8.4 BVC-Reset Procedure */
+static int bssgp_rx_bvc_reset(struct msgb *msg, struct tlv_parsed *tp,
+ uint16_t ns_bvci)
+{
+ uint8_t bvci;
+ int rc;
+
+ bvci = ntohs(*(u_int16_t *)TLVP_VAL(tp, BSSGP_IE_BVCI));
+ DEBUGPC(DGPRS, "BVCI=%u, cause=%s\n", bvci,
+ bssgp_cause_str(*TLVP_VAL(tp, BSSGP_IE_CAUSE)));
+
+ /* When we receive a BVC-RESET PDU (at least of a PTP BVCI), the BSS
+ * informs us about its RAC + Cell ID, so we can create a mapping */
+
+ rc = bssgp_tx_simple_bvci(BSSGP_PDUT_BVC_RESET_ACK,
+ msgb_nsei(msg), bvci, ns_bvci);
+ return 0;
+}
+
/* Uplink unit-data */
static int bssgp_rx_ul_ud(struct msgb *msg, u_int16_t bvci)
{
@@ -157,10 +176,12 @@
!TLVP_PRESENT(&tp, BSSGP_IE_LLC_PDU))
return -EIO;
+#if 0 //FIXME
/* Determine the BTS based on the Cell ID */
bts = gsm48_bts_by_ra_id(bsc_gsmnet,
TLVP_VAL(&tp, BSSGP_IE_CELL_ID),
TLVP_LEN(&tp, BSSGP_IE_CELL_ID));
+#endif
if (bts)
msg->trx = bts->c0;
@@ -229,6 +250,7 @@
return bssgp_tx_fc_bvc_ack(msgb_nsei(msg), *TLVP_VAL(tp, BSSGP_IE_TAG),
ns_bvci);
}
+
/* We expect msg->l3h to point to the BSSGP header */
int gprs_bssgp_rcvmsg(struct msgb *msg, u_int16_t ns_bvci)
{
@@ -311,11 +333,7 @@
if (!TLVP_PRESENT(&tp, BSSGP_IE_BVCI) ||
!TLVP_PRESENT(&tp, BSSGP_IE_CAUSE))
goto err_mand_ie;
- bvci = ntohs(*(u_int16_t *)TLVP_VAL(&tp, BSSGP_IE_BVCI));
- DEBUGPC(DGPRS, "BVCI=%u, cause=%s\n", bvci,
- bssgp_cause_str(*TLVP_VAL(&tp, BSSGP_IE_CAUSE)));
- rc = bssgp_tx_simple_bvci(BSSGP_PDUT_BVC_RESET_ACK,
- msgb_nsei(msg), bvci, ns_bvci);
+ rc = bssgp_rx_bvc_reset(msg, &tp, ns_bvci);
break;
case BSSGP_PDUT_STATUS:
/* Some exception has occurred */