aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-11-09 14:43:33 +0100
committerHarald Welte <laforge@gnumonks.org>2016-11-09 14:43:33 +0100
commit7214a9148eeea567e6934965ee805e65c23ce59f (patch)
tree4d62c884d8bbcbf11736ccfa92541cb87b7a108e
parentc867e1472348c7a551cc83718d2fe74e6baa1c6f (diff)
UNTESTED WIP: remove global bssgp_nsi variablelaforge/gprs-ns-instances
As we can now have several NS instances inside the program, let's remove the global bsspg_nsi to which BSSGP bound itself. Rather, all functions are now parametrized based on the NS Instance that's either * explicitly passed to the function (in case no msgb and no bctx), or * stated in the BVC context / bctx (if any), or * explicitly given as argument to the function (if no msgb and no bctx) Change-Id: Ibc7df60caf4adef690001536bd7a1293d866a1c2
-rw-r--r--include/osmocom/gprs/gprs_bssgp.h10
-rw-r--r--include/osmocom/gprs/gprs_bssgp_bss.h6
-rw-r--r--src/gb/gprs_bssgp.c107
-rw-r--r--src/gb/gprs_bssgp_bss.c45
-rw-r--r--src/gb/gprs_bssgp_util.c13
-rw-r--r--src/gb/libosmogb.map1
6 files changed, 104 insertions, 78 deletions
diff --git a/include/osmocom/gprs/gprs_bssgp.h b/include/osmocom/gprs/gprs_bssgp.h
index b70487c..f349e8a 100644
--- a/include/osmocom/gprs/gprs_bssgp.h
+++ b/include/osmocom/gprs/gprs_bssgp.h
@@ -16,10 +16,10 @@ struct msgb *bssgp_msgb_copy(const struct msgb *msg, const char *name);
const char *bssgp_cause_str(enum gprs_bssgp_cause cause);
const char *bssgp_pdu_str(enum bssgp_pdu_type pdu);
/* Transmit a simple response such as BLOCK/UNBLOCK/RESET ACK/NACK */
-int bssgp_tx_simple_bvci(uint8_t pdu_type, uint16_t nsei,
+int bssgp_tx_simple_bvci(struct gprs_ns_inst *nsi, uint8_t pdu_type, uint16_t nsei,
uint16_t bvci, uint16_t ns_bvci);
/* Chapter 10.4.14: Status */
-int bssgp_tx_status(uint8_t cause, uint16_t *bvci, struct msgb *orig_msg);
+int bssgp_tx_status(struct gprs_ns_inst *nsi, uint8_t cause, uint16_t *bvci, struct msgb *orig_msg);
enum bssgp_prim {
PRIM_BSSGP_DL_UD,
@@ -45,6 +45,7 @@ struct osmo_bssgp_prim {
uint16_t nsei;
uint16_t bvci;
uint32_t tlli;
+ struct gprs_ns_inst *nsi;
struct tlv_parsed *tp;
struct gprs_ra_id *ra_id;
@@ -86,6 +87,7 @@ struct bssgp_bvc_ctx {
struct gprs_ra_id ra_id; /*!< parsed RA ID of the remote BTS */
uint16_t cell_id; /*!< Cell ID of the remote BTS */
+ struct gprs_ns_inst *nsi;
/* NSEI and BVCI of underlying Gb link. Together they
* uniquely identify a link to a BTS (5.4.4) */
uint16_t bvci;
@@ -185,8 +187,8 @@ struct bssgp_paging_info {
};
/* Send a single GMM-PAGING.req to a given NSEI/NS-BVCI */
-int bssgp_tx_paging(uint16_t nsei, uint16_t ns_bvci,
- struct bssgp_paging_info *pinfo);
+int bssgp_tx_paging(struct gprs_ns_inst *nsi, uint16_t nsei,
+ uint16_t ns_bvci, struct bssgp_paging_info *pinfo);
void bssgp_fc_init(struct bssgp_flow_control *fc,
uint32_t bucket_size_max, uint32_t bucket_leak_rate,
diff --git a/include/osmocom/gprs/gprs_bssgp_bss.h b/include/osmocom/gprs/gprs_bssgp_bss.h
index d79b210..1b6f7a6 100644
--- a/include/osmocom/gprs/gprs_bssgp_bss.h
+++ b/include/osmocom/gprs/gprs_bssgp_bss.h
@@ -27,10 +27,10 @@
uint8_t *bssgp_msgb_tlli_put(struct msgb *msg, uint32_t tlli);
-int bssgp_tx_suspend(uint16_t nsei, uint32_t tlli,
- const struct gprs_ra_id *ra_id);
+int bssgp_tx_suspend(struct gprs_ns_inst *nsi, uint16_t nsei,
+ uint32_t tlli, const struct gprs_ra_id *ra_id);
-int bssgp_tx_resume(uint16_t nsei, uint32_t tlli,
+int bssgp_tx_resume(struct gprs_ns_inst *nsi, uint16_t nsei, uint32_t tlli,
const struct gprs_ra_id *ra_id, uint8_t suspend_ref);
int bssgp_tx_ra_capa_upd(struct bssgp_bvc_ctx *bctx, uint32_t tlli, uint8_t tag);
diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c
index 1ee942f..a22f1d9 100644
--- a/src/gb/gprs_bssgp.c
+++ b/src/gb/gprs_bssgp.c
@@ -109,7 +109,8 @@ struct bssgp_bvc_ctx *btsctx_alloc(uint16_t bvci, uint16_t nsei)
}
/* Chapter 10.4.5: Flow Control BVC ACK */
-static int bssgp_tx_fc_bvc_ack(uint16_t nsei, uint8_t tag, uint16_t ns_bvci)
+static int bssgp_tx_fc_bvc_ack(struct gprs_ns_inst *nsi, uint16_t nsei,
+ uint8_t tag, uint16_t ns_bvci)
{
struct msgb *msg = bssgp_msgb_alloc();
struct bssgp_normal_hdr *bgph =
@@ -121,12 +122,13 @@ static int bssgp_tx_fc_bvc_ack(uint16_t nsei, uint8_t tag, uint16_t ns_bvci)
bgph->pdu_type = BSSGP_PDUT_FLOW_CONTROL_BVC_ACK;
msgb_tvlv_put(msg, BSSGP_IE_TAG, 1, &tag);
- return gprs_ns_sendmsg(bssgp_nsi, msg);
+ return gprs_ns_sendmsg(nsi, msg);
}
/* 10.3.7 SUSPEND-ACK PDU */
-int bssgp_tx_suspend_ack(uint16_t nsei, uint32_t tlli,
- const struct gprs_ra_id *ra_id, uint8_t suspend_ref)
+int bssgp_tx_suspend_ack(struct gprs_ns_inst *nsi, uint16_t nsei,
+ uint32_t tlli, const struct gprs_ra_id *ra_id,
+ uint8_t suspend_ref)
{
struct msgb *msg = bssgp_msgb_alloc();
struct bssgp_normal_hdr *bgph =
@@ -144,12 +146,12 @@ int bssgp_tx_suspend_ack(uint16_t nsei, uint32_t tlli,
msgb_tvlv_put(msg, BSSGP_IE_ROUTEING_AREA, 6, ra);
msgb_tvlv_put(msg, BSSGP_IE_SUSPEND_REF_NR, 1, &suspend_ref);
- return gprs_ns_sendmsg(bssgp_nsi, msg);
+ return gprs_ns_sendmsg(nsi, msg);
}
/* 10.3.8 SUSPEND-NACK PDU */
-int bssgp_tx_suspend_nack(uint16_t nsei, uint32_t tlli,
- const struct gprs_ra_id *ra_id,
+int bssgp_tx_suspend_nack(struct gprs_ns_inst *nsi, uint16_t nsei,
+ uint32_t tlli, const struct gprs_ra_id *ra_id,
uint8_t *cause)
{
struct msgb *msg = bssgp_msgb_alloc();
@@ -169,12 +171,12 @@ int bssgp_tx_suspend_nack(uint16_t nsei, uint32_t tlli,
if (cause)
msgb_tvlv_put(msg, BSSGP_IE_CAUSE, 1, cause);
- return gprs_ns_sendmsg(bssgp_nsi, msg);
+ return gprs_ns_sendmsg(nsi, msg);
}
/* 10.3.10 RESUME-ACK PDU */
-int bssgp_tx_resume_ack(uint16_t nsei, uint32_t tlli,
- const struct gprs_ra_id *ra_id)
+int bssgp_tx_resume_ack(struct gprs_ns_inst *nsi, uint16_t nsei,
+ uint32_t tlli, const struct gprs_ra_id *ra_id)
{
struct msgb *msg = bssgp_msgb_alloc();
struct bssgp_normal_hdr *bgph =
@@ -191,12 +193,13 @@ int bssgp_tx_resume_ack(uint16_t nsei, uint32_t tlli,
gsm48_construct_ra(ra, ra_id);
msgb_tvlv_put(msg, BSSGP_IE_ROUTEING_AREA, 6, ra);
- return gprs_ns_sendmsg(bssgp_nsi, msg);
+ return gprs_ns_sendmsg(nsi, msg);
}
/* 10.3.11 RESUME-NACK PDU */
-int bssgp_tx_resume_nack(uint16_t nsei, uint32_t tlli,
- const struct gprs_ra_id *ra_id, uint8_t *cause)
+int bssgp_tx_resume_nack(struct gprs_ns_inst *nsi, uint16_t nsei,
+ uint32_t tlli, const struct gprs_ra_id *ra_id,
+ uint8_t *cause)
{
struct msgb *msg = bssgp_msgb_alloc();
struct bssgp_normal_hdr *bgph =
@@ -215,7 +218,7 @@ int bssgp_tx_resume_nack(uint16_t nsei, uint32_t tlli,
if (cause)
msgb_tvlv_put(msg, BSSGP_IE_CAUSE, 1, cause);
- return gprs_ns_sendmsg(bssgp_nsi, msg);
+ return gprs_ns_sendmsg(nsi, msg);
}
uint16_t bssgp_parse_cell_id(struct gprs_ra_id *raid, const uint8_t *buf)
@@ -242,6 +245,7 @@ int bssgp_create_cell_id(uint8_t *buf, const struct gprs_ra_id *raid,
static int bssgp_rx_bvc_reset(struct msgb *msg, struct tlv_parsed *tp,
uint16_t ns_bvci)
{
+ struct gprs_ns_inst *nsi = msg->dst;
struct osmo_bssgp_prim nmp;
struct bssgp_bvc_ctx *bctx;
uint16_t nsei = msgb_nsei(msg);
@@ -281,18 +285,20 @@ static int bssgp_rx_bvc_reset(struct msgb *msg, struct tlv_parsed *tp,
nmp.bvci = bvci;
nmp.tp = tp;
nmp.ra_id = &bctx->ra_id;
+ nmp.nsi = nsi;
osmo_prim_init(&nmp.oph, SAP_BSSGP_NM, PRIM_NM_BVC_RESET,
PRIM_OP_INDICATION, msg);
bssgp_prim_cb(&nmp.oph, NULL);
/* Acknowledge the RESET to the BTS */
- bssgp_tx_simple_bvci(BSSGP_PDUT_BVC_RESET_ACK,
+ bssgp_tx_simple_bvci(nsi, BSSGP_PDUT_BVC_RESET_ACK,
nsei, bvci, ns_bvci);
return 0;
}
static int bssgp_rx_bvc_block(struct msgb *msg, struct tlv_parsed *tp)
{
+ struct gprs_ns_inst *nsi = msg->dst;
struct osmo_bssgp_prim nmp;
uint16_t bvci;
struct bssgp_bvc_ctx *ptp_ctx;
@@ -310,7 +316,7 @@ static int bssgp_rx_bvc_block(struct msgb *msg, struct tlv_parsed *tp)
ptp_ctx = btsctx_by_bvci_nsei(bvci, msgb_nsei(msg));
if (!ptp_ctx)
- return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI, &bvci, msg);
+ return bssgp_tx_status(nsi, BSSGP_CAUSE_UNKNOWN_BVCI, &bvci, msg);
ptp_ctx->state |= BVC_S_BLOCKED;
rate_ctr_inc(&ptp_ctx->ctrg->ctr[BSSGP_CTR_BLOCKED]);
@@ -320,17 +326,19 @@ static int bssgp_rx_bvc_block(struct msgb *msg, struct tlv_parsed *tp)
nmp.nsei = msgb_nsei(msg);
nmp.bvci = bvci;
nmp.tp = tp;
+ nmp.nsi = nsi;
osmo_prim_init(&nmp.oph, SAP_BSSGP_NM, PRIM_NM_BVC_BLOCK,
PRIM_OP_INDICATION, msg);
bssgp_prim_cb(&nmp.oph, NULL);
/* We always acknowledge the BLOCKing */
- return bssgp_tx_simple_bvci(BSSGP_PDUT_BVC_BLOCK_ACK, msgb_nsei(msg),
+ return bssgp_tx_simple_bvci(nsi, BSSGP_PDUT_BVC_BLOCK_ACK, msgb_nsei(msg),
bvci, msgb_bvci(msg));
};
static int bssgp_rx_bvc_unblock(struct msgb *msg, struct tlv_parsed *tp)
{
+ struct gprs_ns_inst *nsi = msg->dst;
struct osmo_bssgp_prim nmp;
uint16_t bvci;
struct bssgp_bvc_ctx *ptp_ctx;
@@ -348,7 +356,7 @@ static int bssgp_rx_bvc_unblock(struct msgb *msg, struct tlv_parsed *tp)
ptp_ctx = btsctx_by_bvci_nsei(bvci, msgb_nsei(msg));
if (!ptp_ctx)
- return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI, &bvci, msg);
+ return bssgp_tx_status(nsi, BSSGP_CAUSE_UNKNOWN_BVCI, &bvci, msg);
ptp_ctx->state &= ~BVC_S_BLOCKED;
@@ -357,12 +365,13 @@ static int bssgp_rx_bvc_unblock(struct msgb *msg, struct tlv_parsed *tp)
nmp.nsei = msgb_nsei(msg);
nmp.bvci = bvci;
nmp.tp = tp;
+ nmp.nsi = nsi;
osmo_prim_init(&nmp.oph, SAP_BSSGP_NM, PRIM_NM_BVC_UNBLOCK,
PRIM_OP_INDICATION, msg);
bssgp_prim_cb(&nmp.oph, NULL);
/* We always acknowledge the unBLOCKing */
- return bssgp_tx_simple_bvci(BSSGP_PDUT_BVC_UNBLOCK_ACK, msgb_nsei(msg),
+ return bssgp_tx_simple_bvci(nsi, BSSGP_PDUT_BVC_UNBLOCK_ACK, msgb_nsei(msg),
bvci, msgb_bvci(msg));
};
@@ -370,6 +379,7 @@ static int bssgp_rx_bvc_unblock(struct msgb *msg, struct tlv_parsed *tp)
static int bssgp_rx_ul_ud(struct msgb *msg, struct tlv_parsed *tp,
struct bssgp_bvc_ctx *ctx)
{
+ struct gprs_ns_inst *nsi = msg->dst;
struct osmo_bssgp_prim gbp;
struct bssgp_ud_hdr *budh = (struct bssgp_ud_hdr *) msgb_bssgph(msg);
@@ -383,7 +393,7 @@ static int bssgp_rx_ul_ud(struct msgb *msg, struct tlv_parsed *tp,
!TLVP_PRESENT(tp, BSSGP_IE_LLC_PDU)) {
LOGP(DBSSGP, LOGL_ERROR, "BSSGP TLLI=0x%08x Rx UL-UD "
"missing mandatory IE\n", msgb_tlli(msg));
- return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
+ return bssgp_tx_status(ctx->nsi, BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
}
/* store pointer to LLC header and CELL ID in msgb->cb */
@@ -396,6 +406,7 @@ static int bssgp_rx_ul_ud(struct msgb *msg, struct tlv_parsed *tp,
gbp.bvci = ctx->bvci;
gbp.tlli = msgb_tlli(msg);
gbp.tp = tp;
+ gbp.nsi = nsi;
osmo_prim_init(&gbp.oph, SAP_BSSGP_LL, PRIM_BSSGP_UL_UD,
PRIM_OP_INDICATION, msg);
return bssgp_prim_cb(&gbp.oph, NULL);
@@ -403,6 +414,7 @@ static int bssgp_rx_ul_ud(struct msgb *msg, struct tlv_parsed *tp,
static int bssgp_rx_suspend(struct msgb *msg, struct tlv_parsed *tp)
{
+ struct gprs_ns_inst *nsi = msg->dst;
struct osmo_bssgp_prim gbp;
struct gprs_ra_id raid;
uint32_t tlli;
@@ -413,7 +425,7 @@ static int bssgp_rx_suspend(struct msgb *msg, struct tlv_parsed *tp)
!TLVP_PRESENT(tp, BSSGP_IE_ROUTEING_AREA)) {
LOGP(DBSSGP, LOGL_ERROR, "BSSGP BVCI=%u Rx SUSPEND "
"missing mandatory IE\n", ns_bvci);
- return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
+ return bssgp_tx_status(nsi, BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
}
tlli = ntohl(tlvp_val32_unal(tp, BSSGP_IE_TLLI));
@@ -429,20 +441,22 @@ static int bssgp_rx_suspend(struct msgb *msg, struct tlv_parsed *tp)
gbp.bvci = ns_bvci;
gbp.tlli = tlli;
gbp.ra_id = &raid;
+ gbp.nsi = nsi;
osmo_prim_init(&gbp.oph, SAP_BSSGP_GMM, PRIM_BSSGP_GMM_SUSPEND,
PRIM_OP_REQUEST, msg);
rc = bssgp_prim_cb(&gbp.oph, NULL);
if (rc < 0)
- return bssgp_tx_suspend_nack(msgb_nsei(msg), tlli, &raid, NULL);
+ return bssgp_tx_suspend_nack(nsi, msgb_nsei(msg), tlli, &raid, NULL);
- bssgp_tx_suspend_ack(msgb_nsei(msg), tlli, &raid, 0);
+ bssgp_tx_suspend_ack(nsi, msgb_nsei(msg), tlli, &raid, 0);
return 0;
}
static int bssgp_rx_resume(struct msgb *msg, struct tlv_parsed *tp)
{
+ struct gprs_ns_inst *nsi = msg->dst;
struct osmo_bssgp_prim gbp;
struct gprs_ra_id raid;
uint32_t tlli;
@@ -455,7 +469,7 @@ static int bssgp_rx_resume(struct msgb *msg, struct tlv_parsed *tp)
!TLVP_PRESENT(tp, BSSGP_IE_SUSPEND_REF_NR)) {
LOGP(DBSSGP, LOGL_ERROR, "BSSGP BVCI=%u Rx RESUME "
"missing mandatory IE\n", ns_bvci);
- return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
+ return bssgp_tx_status(nsi, BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
}
tlli = ntohl(tlvp_val32_unal(tp, BSSGP_IE_TLLI));
@@ -471,16 +485,17 @@ static int bssgp_rx_resume(struct msgb *msg, struct tlv_parsed *tp)
gbp.bvci = ns_bvci;
gbp.tlli = tlli;
gbp.ra_id = &raid;
+ gbp.nsi = nsi;
gbp.u.resume.suspend_ref = suspend_ref;
osmo_prim_init(&gbp.oph, SAP_BSSGP_GMM, PRIM_BSSGP_GMM_RESUME,
PRIM_OP_REQUEST, msg);
rc = bssgp_prim_cb(&gbp.oph, NULL);
if (rc < 0)
- return bssgp_tx_resume_nack(msgb_nsei(msg), tlli, &raid,
- NULL);
+ return bssgp_tx_resume_nack(nsi, msgb_nsei(msg), tlli,
+ &raid, NULL);
- bssgp_tx_resume_ack(msgb_nsei(msg), tlli, &raid);
+ bssgp_tx_resume_ack(nsi, msgb_nsei(msg), tlli, &raid);
return 0;
}
@@ -488,6 +503,7 @@ static int bssgp_rx_resume(struct msgb *msg, struct tlv_parsed *tp)
static int bssgp_rx_llc_disc(struct msgb *msg, struct tlv_parsed *tp,
struct bssgp_bvc_ctx *ctx)
{
+ struct gprs_ns_inst *nsi = msg->dst;
struct osmo_bssgp_prim nmp;
uint32_t tlli = 0;
@@ -513,6 +529,7 @@ static int bssgp_rx_llc_disc(struct msgb *msg, struct tlv_parsed *tp,
nmp.bvci = ctx->bvci;
nmp.tlli = tlli;
nmp.tp = tp;
+ nmp.nsi = nsi;
osmo_prim_init(&nmp.oph, SAP_BSSGP_NM, PRIM_NM_LLC_DISCARDED,
PRIM_OP_INDICATION, msg);
@@ -522,6 +539,7 @@ static int bssgp_rx_llc_disc(struct msgb *msg, struct tlv_parsed *tp,
int bssgp_rx_status(struct msgb *msg, struct tlv_parsed *tp,
uint16_t bvci, struct bssgp_bvc_ctx *bctx)
{
+ struct gprs_ns_inst *nsi = msg->dst;
struct osmo_bssgp_prim nmp;
enum gprs_bssgp_cause cause;
@@ -552,6 +570,7 @@ int bssgp_rx_status(struct msgb *msg, struct tlv_parsed *tp,
nmp.nsei = msgb_nsei(msg);
nmp.bvci = bvci;
nmp.tp = tp;
+ nmp.nsi = nsi;
osmo_prim_init(&nmp.oph, SAP_BSSGP_NM, PRIM_NM_STATUS,
PRIM_OP_INDICATION, msg);
@@ -724,7 +743,8 @@ pass:
static int _bssgp_tx_dl_ud(struct bssgp_flow_control *fc, struct msgb *msg,
uint32_t llc_pdu_len, void *priv)
{
- return gprs_ns_sendmsg(bssgp_nsi, msg);
+ struct gprs_ns_inst *nsi = msg->dst;
+ return gprs_ns_sendmsg(nsi, msg);
}
/* input function of the flow control implementation, called first
@@ -803,7 +823,7 @@ static int bssgp_rx_fc_bvc(struct msgb *msg, struct tlv_parsed *tp,
!TLVP_PRESENT(tp, BSSGP_IE_R_DEFAULT_MS)) {
LOGP(DBSSGP, LOGL_ERROR, "BSSGP BVCI=%u Rx FC BVC "
"missing mandatory IE\n", bctx->bvci);
- return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
+ return bssgp_tx_status(bctx->nsi, BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
}
/* 11.3.5 Bucket Size in 100 octets unit */
@@ -837,7 +857,7 @@ static int bssgp_rx_fc_bvc(struct msgb *msg, struct tlv_parsed *tp,
fc_queue_timer_cfg(bctx->fc);
/* Send FLOW_CONTROL_BVC_ACK */
- return bssgp_tx_fc_bvc_ack(msgb_nsei(msg), *TLVP_VAL(tp, BSSGP_IE_TAG),
+ return bssgp_tx_fc_bvc_ack(msg->dst, msgb_nsei(msg), *TLVP_VAL(tp, BSSGP_IE_TAG),
msgb_bvci(msg));
}
@@ -857,7 +877,7 @@ static int bssgp_rx_ptp(struct msgb *msg, struct tlv_parsed *tp,
* BVC Blocked) shall be sent to the peer entity on the signalling BVC */
if (bctx->state & BVC_S_BLOCKED) {
uint16_t bvci = msgb_bvci(msg);
- return bssgp_tx_status(BSSGP_CAUSE_BVCI_BLOCKED, &bvci, msg);
+ return bssgp_tx_status(bctx->nsi, BSSGP_CAUSE_BVCI_BLOCKED, &bvci, msg);
}
switch (pdu_type) {
@@ -898,7 +918,7 @@ static int bssgp_rx_ptp(struct msgb *msg, struct tlv_parsed *tp,
case BSSGP_PDUT_DELETE_BSS_PFC_ACK:
DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type %s not [yet] "
"implemented\n", bctx->bvci, bssgp_pdu_str(pdu_type));
- rc = bssgp_tx_status(BSSGP_CAUSE_PDU_INCOMP_FEAT, NULL, msg);
+ rc = bssgp_tx_status(bctx->nsi, BSSGP_CAUSE_PDU_INCOMP_FEAT, NULL, msg);
break;
/* those only exist in the SGSN -> BSS direction */
case BSSGP_PDUT_DL_UNITDATA:
@@ -909,13 +929,13 @@ static int bssgp_rx_ptp(struct msgb *msg, struct tlv_parsed *tp,
case BSSGP_PDUT_FLOW_CONTROL_MS_ACK:
DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type %s only exists in DL\n",
bctx->bvci, bssgp_pdu_str(pdu_type));
- bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
+ bssgp_tx_status(bctx->nsi, BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
rc = -EINVAL;
break;
default:
DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type %s unknown\n",
bctx->bvci, bssgp_pdu_str(pdu_type));
- rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
+ rc = bssgp_tx_status(bctx->nsi, BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
break;
}
@@ -1001,24 +1021,25 @@ static int bssgp_rx_sign(struct msgb *msg, struct tlv_parsed *tp,
case BSSGP_PDUT_SGSN_INVOKE_TRACE:
DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type %s only exists in DL\n",
bvci, bssgp_pdu_str(pdu_type));
- bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
+ bssgp_tx_status(bctx->nsi, BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
rc = -EINVAL;
break;
default:
DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type %s unknown\n",
bvci, bssgp_pdu_str(pdu_type));
- rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
+ rc = bssgp_tx_status(bctx->nsi, BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
break;
}
return rc;
err_mand_ie:
- return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
+ return bssgp_tx_status(bctx->nsi, BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
}
/* We expect msgb_bssgph() to point to the BSSGP header */
int bssgp_rcvmsg(struct msgb *msg)
{
+ struct gprs_ns_inst *nsi = msg->dst;
struct bssgp_normal_hdr *bgph =
(struct bssgp_normal_hdr *) msgb_bssgph(msg);
struct bssgp_ud_hdr *budh = (struct bssgp_ud_hdr *) msgb_bssgph(msg);
@@ -1030,6 +1051,8 @@ int bssgp_rcvmsg(struct msgb *msg)
int data_len;
int rc = 0;
+ OSMO_ASSERT(nsi);
+
/* Identifiers from DOWN: NSEI, BVCI (both in msg->cb) */
/* UNITDATA BSSGP headers have TLLI in front */
@@ -1068,13 +1091,13 @@ int bssgp_rcvmsg(struct msgb *msg)
LOGP(DBSSGP, LOGL_NOTICE, "NSEI=%u/BVCI=%u Rejecting PDU "
"type %s for unknown BVCI\n", msgb_nsei(msg), bvci,
bssgp_pdu_str(pdu_type));
- return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI, &bvci, msg);
+ return bssgp_tx_status(nsi, BSSGP_CAUSE_UNKNOWN_BVCI, &bvci, msg);
}
if (ns_bvci == BVCI_SIGNALLING)
rc = bssgp_rx_sign(msg, &tp, bctx);
else if (ns_bvci == BVCI_PTM)
- rc = bssgp_tx_status(BSSGP_CAUSE_PDU_INCOMP_FEAT, NULL, msg);
+ rc = bssgp_tx_status(nsi, BSSGP_CAUSE_PDU_INCOMP_FEAT, NULL, msg);
else if (bctx)
rc = bssgp_rx_ptp(msg, &tp, bctx);
else
@@ -1183,8 +1206,8 @@ int bssgp_tx_dl_ud(struct msgb *msg, uint16_t pdu_lifetime,
}
/* Send a single GMM-PAGING.req to a given NSEI/NS-BVCI */
-int bssgp_tx_paging(uint16_t nsei, uint16_t ns_bvci,
- struct bssgp_paging_info *pinfo)
+int bssgp_tx_paging(struct gprs_ns_inst *nsi, uint16_t nsei,
+ uint16_t ns_bvci, struct bssgp_paging_info *pinfo)
{
struct msgb *msg = bssgp_msgb_alloc();
struct bssgp_normal_hdr *bgph =
@@ -1242,7 +1265,7 @@ int bssgp_tx_paging(uint16_t nsei, uint16_t ns_bvci,
msgb_tvlv_put(msg, BSSGP_IE_TMSI, 4, (uint8_t *) &ptmsi);
}
- return gprs_ns_sendmsg(bssgp_nsi, msg);
+ return gprs_ns_sendmsg(nsi, msg);
}
void bssgp_set_log_ss(int ss)
diff --git a/src/gb/gprs_bssgp_bss.c b/src/gb/gprs_bssgp_bss.c
index 61ed0c4..2264cf9 100644
--- a/src/gb/gprs_bssgp_bss.c
+++ b/src/gb/gprs_bssgp_bss.c
@@ -43,8 +43,8 @@ uint8_t *bssgp_msgb_tlli_put(struct msgb *msg, uint32_t tlli)
}
/*! \brief GMM-SUSPEND.req (Chapter 10.3.6) */
-int bssgp_tx_suspend(uint16_t nsei, uint32_t tlli,
- const struct gprs_ra_id *ra_id)
+int bssgp_tx_suspend(struct gprs_ns_inst *nsi, uint16_t nsei,
+ uint32_t tlli, const struct gprs_ra_id *ra_id)
{
struct msgb *msg = bssgp_msgb_alloc();
struct bssgp_normal_hdr *bgph =
@@ -62,12 +62,13 @@ int bssgp_tx_suspend(uint16_t nsei, uint32_t tlli,
gsm48_construct_ra(ra, ra_id);
msgb_tvlv_put(msg, BSSGP_IE_ROUTEING_AREA, 6, ra);
- return gprs_ns_sendmsg(bssgp_nsi, msg);
+ return gprs_ns_sendmsg(nsi, msg);
}
/*! \brief GMM-RESUME.req (Chapter 10.3.9) */
-int bssgp_tx_resume(uint16_t nsei, uint32_t tlli,
- const struct gprs_ra_id *ra_id, uint8_t suspend_ref)
+int bssgp_tx_resume(struct gprs_ns_inst *nsi, uint16_t nsei,
+ uint32_t tlli, const struct gprs_ra_id *ra_id,
+ uint8_t suspend_ref)
{
struct msgb *msg = bssgp_msgb_alloc();
struct bssgp_normal_hdr *bgph =
@@ -87,11 +88,12 @@ int bssgp_tx_resume(uint16_t nsei, uint32_t tlli,
msgb_tvlv_put(msg, BSSGP_IE_SUSPEND_REF_NR, 1, &suspend_ref);
- return gprs_ns_sendmsg(bssgp_nsi, msg);
+ return gprs_ns_sendmsg(nsi, msg);
}
/*! \brief Transmit RA-CAPABILITY-UPDATE (10.3.3) */
-int bssgp_tx_ra_capa_upd(struct bssgp_bvc_ctx *bctx, uint32_t tlli, uint8_t tag)
+int bssgp_tx_ra_capa_upd(struct bssgp_bvc_ctx *bctx, uint32_t tlli,
+ uint8_t tag)
{
struct msgb *msg = bssgp_msgb_alloc();
struct bssgp_normal_hdr *bgph =
@@ -109,7 +111,7 @@ int bssgp_tx_ra_capa_upd(struct bssgp_bvc_ctx *bctx, uint32_t tlli, uint8_t tag)
msgb_tvlv_put(msg, BSSGP_IE_TAG, 1, &tag);
- return gprs_ns_sendmsg(bssgp_nsi, msg);
+ return gprs_ns_sendmsg(bctx->nsi, msg);
}
/* first common part of RADIO-STATUS */
@@ -132,12 +134,13 @@ static struct msgb *common_tx_radio_status(struct bssgp_bvc_ctx *bctx)
}
/* second common part of RADIO-STATUS */
-static int common_tx_radio_status2(struct msgb *msg, uint8_t cause)
+static int common_tx_radio_status2(struct gprs_ns_inst *nsi,
+ struct msgb *msg, uint8_t cause)
{
msgb_tvlv_put(msg, BSSGP_IE_CAUSE, 1, &cause);
LOGPC(DBSSGP, LOGL_NOTICE, "CAUSE=%s\n", bssgp_cause_str(cause));
- return gprs_ns_sendmsg(bssgp_nsi, msg);
+ return gprs_ns_sendmsg(nsi, msg);
}
/*! \brief Transmit RADIO-STATUS for TLLI (10.3.5) */
@@ -151,7 +154,7 @@ int bssgp_tx_radio_status_tlli(struct bssgp_bvc_ctx *bctx, uint8_t cause,
bssgp_msgb_tlli_put(msg, tlli);
LOGPC(DBSSGP, LOGL_NOTICE, "TLLI=0x%08x ", tlli);
- return common_tx_radio_status2(msg, cause);
+ return common_tx_radio_status2(bctx->nsi, msg, cause);
}
/*! \brief Transmit RADIO-STATUS for TMSI (10.3.5) */
@@ -166,7 +169,7 @@ int bssgp_tx_radio_status_tmsi(struct bssgp_bvc_ctx *bctx, uint8_t cause,
msgb_tvlv_put(msg, BSSGP_IE_TMSI, 4, (uint8_t *)&_tmsi);
LOGPC(DBSSGP, LOGL_NOTICE, "TMSI=0x%08x ", tmsi);
- return common_tx_radio_status2(msg, cause);
+ return common_tx_radio_status2(bctx->nsi, msg, cause);
}
/*! \brief Transmit RADIO-STATUS for IMSI (10.3.5) */
@@ -185,7 +188,7 @@ int bssgp_tx_radio_status_imsi(struct bssgp_bvc_ctx *bctx, uint8_t cause,
msgb_tvlv_put(msg, BSSGP_IE_IMSI, imsi_len-2, mi+2);
LOGPC(DBSSGP, LOGL_NOTICE, "IMSI=%s ", imsi);
- return common_tx_radio_status2(msg, cause);
+ return common_tx_radio_status2(bctx->nsi, msg, cause);
}
/*! \brief Transmit FLUSH-LL-ACK (Chapter 10.4.2) */
@@ -209,7 +212,7 @@ int bssgp_tx_flush_ll_ack(struct bssgp_bvc_ctx *bctx, uint32_t tlli,
msgb_tvlv_put(msg, BSSGP_IE_BVCI, 2, (uint8_t *) &_bvci_new);
msgb_tvlv_put(msg, BSSGP_IE_NUM_OCT_AFF, 3, (uint8_t *) &_oct_aff);
- return gprs_ns_sendmsg(bssgp_nsi, msg);
+ return gprs_ns_sendmsg(bctx->nsi, msg);
}
/*! \brief Transmit LLC-DISCARDED (Chapter 10.4.3) */
@@ -235,7 +238,7 @@ int bssgp_tx_llc_discarded(struct bssgp_bvc_ctx *bctx, uint32_t tlli,
msgb_tvlv_put(msg, BSSGP_IE_BVCI, 2, (uint8_t *) &_bvci);
msgb_tvlv_put(msg, BSSGP_IE_NUM_OCT_AFF, 3, ((uint8_t *) &_oct_aff) + 1);
- return gprs_ns_sendmsg(bssgp_nsi, msg);
+ return gprs_ns_sendmsg(bctx->nsi, msg);
}
/*! \brief Transmit a BVC-BLOCK message (Chapter 10.4.8) */
@@ -256,7 +259,7 @@ int bssgp_tx_bvc_block(struct bssgp_bvc_ctx *bctx, uint8_t cause)
msgb_tvlv_put(msg, BSSGP_IE_BVCI, 2, (uint8_t *) &_bvci);
msgb_tvlv_put(msg, BSSGP_IE_CAUSE, 1, &cause);
- return gprs_ns_sendmsg(bssgp_nsi, msg);
+ return gprs_ns_sendmsg(bctx->nsi, msg);
}
/*! \brief Transmit a BVC-UNBLOCK message (Chapter 10.4.10) */
@@ -275,7 +278,7 @@ int bssgp_tx_bvc_unblock(struct bssgp_bvc_ctx *bctx)
msgb_tvlv_put(msg, BSSGP_IE_BVCI, 2, (uint8_t *) &_bvci);
- return gprs_ns_sendmsg(bssgp_nsi, msg);
+ return gprs_ns_sendmsg(bctx->nsi, msg);
}
/*! \brief Transmit a BVC-RESET message (Chapter 10.4.12) */
@@ -302,7 +305,7 @@ int bssgp_tx_bvc_reset(struct bssgp_bvc_ctx *bctx, uint16_t bvci, uint8_t cause)
}
/* Optional: Feature Bitmap */
- return gprs_ns_sendmsg(bssgp_nsi, msg);
+ return gprs_ns_sendmsg(bctx->nsi, msg);
}
/*! \brief Transmit a FLOW_CONTROL-BVC (Chapter 10.4.4)
@@ -374,7 +377,7 @@ int bssgp_tx_fc_bvc(struct bssgp_bvc_ctx *bctx, uint8_t tag,
sizeof(e_queue_delay),
(uint8_t *) &e_queue_delay);
- return gprs_ns_sendmsg(bssgp_nsi, msg);
+ return gprs_ns_sendmsg(bctx->nsi, msg);
}
/*! \brief Transmit a FLOW_CONTROL-MS (Chapter 10.4.6)
@@ -419,7 +422,7 @@ int bssgp_tx_fc_ms(struct bssgp_bvc_ctx *bctx, uint32_t tlli, uint8_t tag,
msgb_tvlv_put(msg, BSSGP_IE_BUCKET_FULL_RATIO,
1, bucket_full_ratio);
- return gprs_ns_sendmsg(bssgp_nsi, msg);
+ return gprs_ns_sendmsg(bctx->nsi, msg);
}
/*! \brief RL-UL-UNITDATA.req (Chapter 10.2.2)
@@ -465,7 +468,7 @@ int bssgp_tx_ul_ud(struct bssgp_bvc_ctx *bctx, uint32_t tlli,
rate_ctr_inc(&bctx->ctrg->ctr[BSSGP_CTR_PKTS_OUT]);
rate_ctr_add(&bctx->ctrg->ctr[BSSGP_CTR_BYTES_OUT], msg->len);
- return gprs_ns_sendmsg(bssgp_nsi, msg);
+ return gprs_ns_sendmsg(bctx->nsi, msg);
}
/* Parse a single GMM-PAGING.req to a given NSEI/NS-BVCI */
diff --git a/src/gb/gprs_bssgp_util.c b/src/gb/gprs_bssgp_util.c
index 6fff362..864bb3f 100644
--- a/src/gb/gprs_bssgp_util.c
+++ b/src/gb/gprs_bssgp_util.c
@@ -32,8 +32,6 @@
#include "common_vty.h"
-struct gprs_ns_inst *bssgp_nsi;
-
/* BSSGP Protocol specific, not implementation specific */
/* FIXME: This needs to go into libosmocore after finished */
@@ -156,8 +154,8 @@ struct msgb *bssgp_msgb_copy(const struct msgb *msg, const char *name)
}
/* Transmit a simple response such as BLOCK/UNBLOCK/RESET ACK/NACK */
-int bssgp_tx_simple_bvci(uint8_t pdu_type, uint16_t nsei,
- uint16_t bvci, uint16_t ns_bvci)
+int bssgp_tx_simple_bvci(struct gprs_ns_inst *nsi, uint8_t pdu_type,
+ uint16_t nsei, uint16_t bvci, uint16_t ns_bvci)
{
struct msgb *msg = bssgp_msgb_alloc();
struct bssgp_normal_hdr *bgph =
@@ -171,11 +169,12 @@ int bssgp_tx_simple_bvci(uint8_t pdu_type, uint16_t nsei,
_bvci = htons(bvci);
msgb_tvlv_put(msg, BSSGP_IE_BVCI, 2, (uint8_t *) &_bvci);
- return gprs_ns_sendmsg(bssgp_nsi, msg);
+ return gprs_ns_sendmsg(nsi, msg);
}
/* Chapter 10.4.14: Status */
-int bssgp_tx_status(uint8_t cause, uint16_t *bvci, struct msgb *orig_msg)
+int bssgp_tx_status(struct gprs_ns_inst *nsi, uint8_t cause,
+ uint16_t *bvci, struct msgb *orig_msg)
{
struct msgb *msg = bssgp_msgb_alloc();
struct bssgp_normal_hdr *bgph =
@@ -209,5 +208,5 @@ int bssgp_tx_status(uint8_t cause, uint16_t *bvci, struct msgb *orig_msg)
msgb_tvlv_put(msg, BSSGP_IE_PDU_IN_ERROR,
msgb_bssgp_len(orig_msg), msgb_bssgph(orig_msg));
- return gprs_ns_sendmsg(bssgp_nsi, msg);
+ return gprs_ns_sendmsg(nsi, msg);
}
diff --git a/src/gb/libosmogb.map b/src/gb/libosmogb.map
index 76ce3fb..3b70e47 100644
--- a/src/gb/libosmogb.map
+++ b/src/gb/libosmogb.map
@@ -36,7 +36,6 @@ bssgp_set_log_ss;
bssgp_tx_dl_ud;
bssgp_tx_paging;
bssgp_vty_init;
-bssgp_nsi;
gprs_ns_cause_str;
gprs_ns_destroy;