aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-06-26 04:25:15 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2018-06-26 04:54:46 +0200
commit2dd8ebe36205f660bc972e9c4479a96365c37399 (patch)
tree22d0f6c2e54ef13ba7092a0319b67063c61a3340
parentd7e3dbcd5b0ac44106021ddb22b34d1695f38de3 (diff)
replace the GET_FOO() macros in fsm implementations
-rw-r--r--src/osmo-bsc/assignment_fsm.c31
-rw-r--r--src/osmo-bsc/handover_fsm.c45
-rw-r--r--src/osmo-bsc/lchan_fsm.c60
-rw-r--r--src/osmo-bsc/mgw_endpoint_fsm.c21
-rw-r--r--src/osmo-bsc/timeslot_fsm.c42
5 files changed, 106 insertions, 93 deletions
diff --git a/src/osmo-bsc/assignment_fsm.c b/src/osmo-bsc/assignment_fsm.c
index f24766180..b811ad1e0 100644
--- a/src/osmo-bsc/assignment_fsm.c
+++ b/src/osmo-bsc/assignment_fsm.c
@@ -40,10 +40,13 @@
static struct osmo_fsm assignment_fsm;
-/* From local var fi->priv, define local var conn. */
-#define GET_CONN() \
- struct gsm_subscriber_connection *conn = fi->priv; \
- OSMO_ASSERT((fi)->fsm == &assignment_fsm && (fi)->priv)
+struct gsm_subscriber_connection *assignment_fi_conn(struct osmo_fsm_inst *fi)
+{
+ OSMO_ASSERT(fi);
+ OSMO_ASSERT(fi->fsm == &assignment_fsm);
+ OSMO_ASSERT(fi->priv);
+ return fi->priv;
+}
static const struct state_timeout assignment_fsm_timeouts[32] = {
[ASSIGNMENT_ST_WAIT_LCHAN_ACTIVE] = { .T=10 },
@@ -386,7 +389,7 @@ void assignment_fsm_start(struct gsm_subscriber_connection *conn, struct gsm_bts
static void assignment_fsm_wait_lchan(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- GET_CONN();
+ struct gsm_subscriber_connection *conn = assignment_fi_conn(fi);
switch (event) {
case ASSIGNMENT_EV_LCHAN_ACTIVE:
@@ -404,7 +407,7 @@ static void assignment_fsm_wait_lchan(struct osmo_fsm_inst *fi, uint32_t event,
static void assignment_fsm_wait_rr_ass_complete_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
int rc;
- GET_CONN();
+ struct gsm_subscriber_connection *conn = assignment_fi_conn(fi);
rc = gsm48_send_rr_ass_cmd(conn->lchan, conn->assignment.new_lchan,
conn->lchan->ms_power);
@@ -422,7 +425,7 @@ static uint8_t get_cause(void *data)
static void assignment_fsm_wait_rr_ass_complete(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- GET_CONN();
+ struct gsm_subscriber_connection *conn = assignment_fi_conn(fi);
switch (event) {
case ASSIGNMENT_EV_RR_ASSIGNMENT_COMPLETE:
@@ -441,14 +444,14 @@ static void assignment_fsm_wait_rr_ass_complete(struct osmo_fsm_inst *fi, uint32
static void assignment_fsm_wait_lchan_established_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
- GET_CONN();
+ struct gsm_subscriber_connection *conn = assignment_fi_conn(fi);
/* The RR Assignment Complete counts as RLL Establish event */
osmo_fsm_inst_dispatch(conn->assignment.new_lchan->fi, LCHAN_EV_RLL_ESTABLISH_IND, 0);
}
static void assignment_fsm_wait_lchan_established(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- GET_CONN();
+ struct gsm_subscriber_connection *conn = assignment_fi_conn(fi);
switch (event) {
case ASSIGNMENT_EV_LCHAN_ESTABLISHED:
@@ -465,7 +468,7 @@ static void assignment_fsm_wait_lchan_established(struct osmo_fsm_inst *fi, uint
static void assignment_fsm_wait_mgw_endpoint_to_msc_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
- GET_CONN();
+ struct gsm_subscriber_connection *conn = assignment_fi_conn(fi);
OSMO_ASSERT(conn->assignment.requires_voice_stream);
@@ -492,7 +495,7 @@ static void assignment_fsm_wait_mgw_endpoint_to_msc_onenter(struct osmo_fsm_inst
static void assignment_fsm_wait_mgw_endpoint_to_msc(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
const struct mgcp_conn_peer *mgw_info;
- GET_CONN();
+ struct gsm_subscriber_connection *conn = assignment_fi_conn(fi);
switch (event) {
case ASSIGNMENT_EV_MSC_MGW_OK:
@@ -579,7 +582,7 @@ static const struct value_string assignment_fsm_event_names[] = {
void assignment_fsm_allstate_action(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- GET_CONN();
+ struct gsm_subscriber_connection *conn = assignment_fi_conn(fi);
switch (event) {
case ASSIGNMENT_EV_CONN_RELEASING:
@@ -602,7 +605,7 @@ void assignment_fsm_allstate_action(struct osmo_fsm_inst *fi, uint32_t event, vo
int assignment_fsm_timer_cb(struct osmo_fsm_inst *fi)
{
- GET_CONN();
+ struct gsm_subscriber_connection *conn = assignment_fi_conn(fi);
assignment_count_result(BSC_CTR_ASSIGNMENT_TIMEOUT);
assignment_fail(GSM0808_CAUSE_EQUIPMENT_FAILURE, "Timeout");
return 0;
@@ -610,7 +613,7 @@ int assignment_fsm_timer_cb(struct osmo_fsm_inst *fi)
void assignment_fsm_cleanup(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause)
{
- GET_CONN();
+ struct gsm_subscriber_connection *conn = assignment_fi_conn(fi);
assignment_reset(conn);
conn->assignment.fi = NULL;
}
diff --git a/src/osmo-bsc/handover_fsm.c b/src/osmo-bsc/handover_fsm.c
index 5a97a79bb..60405d31f 100644
--- a/src/osmo-bsc/handover_fsm.c
+++ b/src/osmo-bsc/handover_fsm.c
@@ -138,14 +138,13 @@ const char *handover_status(struct gsm_subscriber_connection *conn)
static struct osmo_fsm ho_fsm;
-/* From local var fi->priv, define local var conn. */
-#define GET_CONN() \
- struct gsm_subscriber_connection *conn = fi->priv; \
- OSMO_ASSERT((fi)->fsm == &ho_fsm && (fi)->priv) \
-
-#define GET_HO() \
- GET_CONN(); \
- struct handover *ho = &conn->ho
+struct gsm_subscriber_connection *ho_fi_conn(struct osmo_fsm_inst *fi)
+{
+ OSMO_ASSERT(fi);
+ OSMO_ASSERT(fi->fsm == &ho_fsm);
+ OSMO_ASSERT(fi->priv);
+ return fi->priv;
+}
static const struct state_timeout ho_fsm_timeouts[32] = {
[HO_ST_WAIT_LCHAN_ACTIVE] = { .T = 23042 },
@@ -219,7 +218,7 @@ insane:
static void ho_fsm_update_id(struct osmo_fsm_inst *fi, const char *label)
{
- GET_CONN();
+ struct gsm_subscriber_connection *conn = ho_fi_conn(fi);
if (conn->fi->id)
osmo_fsm_inst_update_id_f(fi, "%s_%s", label, conn->fi->id);
else
@@ -714,7 +713,7 @@ void handover_end(struct gsm_subscriber_connection *conn, enum handover_result r
static void ho_fsm_wait_lchan_active(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- GET_CONN();
+ struct gsm_subscriber_connection *conn = ho_fi_conn(fi);
switch (event) {
case HO_EV_LCHAN_ACTIVE:
@@ -734,7 +733,7 @@ static void ho_fsm_wait_lchan_active(struct osmo_fsm_inst *fi, uint32_t event, v
static void ho_fsm_wait_rr_ho_detect_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
int rc;
- GET_CONN();
+ struct gsm_subscriber_connection *conn = ho_fi_conn(fi);
struct handover *ho = &conn->ho;
struct msgb *rr_ho_cmd = gsm48_make_ho_cmd(ho->mt.new_lchan,
@@ -769,7 +768,8 @@ static void ho_fsm_wait_rr_ho_detect_onenter(struct osmo_fsm_inst *fi, uint32_t
static void ho_fsm_wait_rr_ho_detect(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- GET_HO();
+ struct gsm_subscriber_connection *conn = ho_fi_conn(fi);
+ struct handover *ho = &conn->ho;
switch (event) {
case HO_EV_RR_HO_DETECT:
@@ -814,7 +814,7 @@ static void ho_fsm_wait_rr_ho_detect(struct osmo_fsm_inst *fi, uint32_t event, v
static void ho_fsm_wait_rr_ho_complete(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- GET_CONN();
+ struct gsm_subscriber_connection *conn = ho_fi_conn(fi);
switch (event) {
@@ -835,7 +835,8 @@ static void ho_fsm_post_lchan_established(struct osmo_fsm_inst *fi);
static void ho_fsm_wait_lchan_established_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
- GET_HO();
+ struct gsm_subscriber_connection *conn = ho_fi_conn(fi);
+ struct handover *ho = &conn->ho;
/* The RR Assignment Complete counts as RLL Establish event */
osmo_fsm_inst_dispatch(ho->mt.new_lchan->fi, LCHAN_EV_RLL_ESTABLISH_IND, 0);
@@ -860,7 +861,8 @@ static void ho_fsm_wait_lchan_established(struct osmo_fsm_inst *fi, uint32_t eve
static void ho_fsm_post_lchan_established(struct osmo_fsm_inst *fi)
{
- GET_HO();
+ struct gsm_subscriber_connection *conn = ho_fi_conn(fi);
+ struct handover *ho = &conn->ho;
if (ho->mt.new_lchan->activate.requires_voice_stream
&& (ho->scope & HO_INTER_BSC_MT))
@@ -871,7 +873,8 @@ static void ho_fsm_post_lchan_established(struct osmo_fsm_inst *fi)
static void ho_fsm_wait_mgw_endpoint_to_msc_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
- GET_HO();
+ struct gsm_subscriber_connection *conn = ho_fi_conn(fi);
+ struct handover *ho = &conn->ho;
if (!gscon_connect_mgw_to_msc(conn,
ho->mt.new_lchan,
@@ -889,7 +892,7 @@ static void ho_fsm_wait_mgw_endpoint_to_msc_onenter(struct osmo_fsm_inst *fi, ui
static void ho_fsm_wait_mgw_endpoint_to_msc(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- GET_CONN();
+ struct gsm_subscriber_connection *conn = ho_fi_conn(fi);
switch (event) {
case HO_EV_MSC_MGW_OK:
@@ -932,7 +935,7 @@ static void moho_fsm_wait_ho_command(struct osmo_fsm_inst *fi, uint32_t event, v
{
int rc;
struct moho_rx_bssmap_ho_command *rx;
- GET_CONN();
+ struct gsm_subscriber_connection *conn = ho_fi_conn(fi);
switch (event) {
case MOHO_EV_BSSMAP_HO_COMMAND:
@@ -1062,7 +1065,7 @@ static const struct value_string ho_fsm_event_names[] = {
void ho_fsm_allstate_action(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- GET_CONN();
+ struct gsm_subscriber_connection *conn = ho_fi_conn(fi);
switch (event) {
case HO_EV_CONN_RELEASING:
@@ -1097,14 +1100,14 @@ void ho_fsm_allstate_action(struct osmo_fsm_inst *fi, uint32_t event, void *data
int ho_fsm_timer_cb(struct osmo_fsm_inst *fi)
{
- GET_CONN();
+ struct gsm_subscriber_connection *conn = ho_fi_conn(fi);
ho_fail(HO_RESULT_FAIL_TIMEOUT, "Timeout");
return 0;
}
void ho_fsm_cleanup(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause)
{
- GET_CONN();
+ struct gsm_subscriber_connection *conn = ho_fi_conn(fi);
conn->ho.fi = NULL;
}
diff --git a/src/osmo-bsc/lchan_fsm.c b/src/osmo-bsc/lchan_fsm.c
index f9a778143..cf107979c 100644
--- a/src/osmo-bsc/lchan_fsm.c
+++ b/src/osmo-bsc/lchan_fsm.c
@@ -38,11 +38,13 @@
static struct osmo_fsm lchan_fsm;
-#define GET_LCHAN() \
- struct gsm_lchan *lchan = fi->priv; \
- OSMO_ASSERT((fi)->fsm == &lchan_fsm); \
- OSMO_ASSERT((fi)->priv); \
- OSMO_ASSERT(lchan->fi == (fi))
+struct gsm_lchan *lchan_fi_lchan(struct osmo_fsm_inst *fi)
+{
+ OSMO_ASSERT(fi);
+ OSMO_ASSERT(fi->fsm == &lchan_fsm);
+ OSMO_ASSERT(fi->priv);
+ return fi->priv;
+}
bool lchan_may_receive_data(struct gsm_lchan *lchan)
{
@@ -372,7 +374,7 @@ static void lchan_reset(struct gsm_lchan *lchan)
static void lchan_fsm_unused_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
lchan_reset(lchan);
osmo_fsm_inst_dispatch(lchan->ts->fi, TS_EV_LCHAN_UNUSED, lchan);
}
@@ -380,7 +382,7 @@ static void lchan_fsm_unused_onenter(struct osmo_fsm_inst *fi, uint32_t prev_sta
static void lchan_fsm_unused(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
struct lchan_activate_info *info = data;
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
switch (event) {
case LCHAN_EV_ACTIVATE:
@@ -444,7 +446,7 @@ static void lchan_fsm_wait_ts_ready_onenter(struct osmo_fsm_inst *fi, uint32_t p
{
struct mgw_endpoint *mgwep;
struct mgcp_conn_peer crcx_info = {};
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
if (lchan->release_requested) {
lchan_fail("Release requested while activating");
@@ -497,7 +499,7 @@ static void lchan_fsm_wait_ts_ready_onenter(struct osmo_fsm_inst *fi, uint32_t p
static void lchan_fsm_wait_ts_ready(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
switch (event) {
case LCHAN_EV_TS_READY:
@@ -520,7 +522,7 @@ static void lchan_fsm_wait_activ_ack_onenter(struct osmo_fsm_inst *fi, uint32_t
int rc;
uint8_t act_type;
uint8_t ho_ref = 0;
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
if (lchan->release_requested) {
lchan_fail_to(LCHAN_ST_UNUSED, "Release requested while activating");
@@ -548,7 +550,7 @@ static void lchan_fsm_wait_activ_ack_onenter(struct osmo_fsm_inst *fi, uint32_t
static void lchan_fsm_wait_activ_ack(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
switch (event) {
case LCHAN_EV_MGW_ENDPOINT_AVAILABLE:
@@ -589,7 +591,7 @@ static void lchan_fsm_wait_activ_ack(struct osmo_fsm_inst *fi, uint32_t event, v
static void lchan_fsm_wait_rll_establish_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
int rc;
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
if (lchan->release_requested) {
lchan_fail_to(LCHAN_ST_WAIT_RF_RELEASE_ACK, "Release requested while activating");
return;
@@ -656,7 +658,7 @@ static void lchan_fsm_wait_rll_establish_onenter(struct osmo_fsm_inst *fi, uint3
static void lchan_fsm_wait_rll_establish(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
switch (event) {
case LCHAN_EV_MGW_ENDPOINT_AVAILABLE:
@@ -683,7 +685,7 @@ static void lchan_fsm_tch_post_endpoint_available(struct osmo_fsm_inst *fi);
static void lchan_fsm_wait_mgw_endpoint_available_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
if (lchan->release_requested) {
lchan_fail("Release requested while activating");
@@ -698,7 +700,7 @@ static void lchan_fsm_wait_mgw_endpoint_available_onenter(struct osmo_fsm_inst *
static void lchan_fsm_wait_mgw_endpoint_available(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
switch (event) {
case LCHAN_EV_MGW_ENDPOINT_AVAILABLE:
@@ -713,7 +715,7 @@ static void lchan_fsm_wait_mgw_endpoint_available(struct osmo_fsm_inst *fi, uint
static void lchan_fsm_tch_post_endpoint_available(struct osmo_fsm_inst *fi)
{
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
LOG_LCHAN(lchan, LOGL_DEBUG, "MGW endpoint: %s",
mgcp_conn_peer_name(mgwep_ci_get_rtp_info(lchan->mgw_endpoint_ci_bts)));
@@ -728,7 +730,7 @@ static void lchan_fsm_wait_ipacc_crcx_ack_onenter(struct osmo_fsm_inst *fi, uint
{
int rc;
int val;
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
if (lchan->release_requested) {
lchan_fail("Release requested while activating");
@@ -785,7 +787,7 @@ static void lchan_fsm_wait_ipacc_crcx_ack(struct osmo_fsm_inst *fi, uint32_t eve
static void lchan_fsm_wait_ipacc_mdcx_ack_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
int rc;
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
uint32_t ip = lchan->abis_ip.bound_ip;
int port = lchan->abis_ip.bound_port;
@@ -846,7 +848,7 @@ static void lchan_fsm_wait_mgw_endpoint_configured_onenter(struct osmo_fsm_inst
struct mgcp_conn_peer mdcx_info;
struct in_addr addr;
const char *addr_str;
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
if (lchan->release_requested) {
lchan_fail("Release requested while activating");
@@ -900,7 +902,7 @@ static void lchan_fsm_wait_mgw_endpoint_configured(struct osmo_fsm_inst *fi, uin
static void lchan_fsm_established_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
if (lchan->release_requested) {
lchan_fail("Release requested while activating");
@@ -950,7 +952,7 @@ static void handle_rll_rel_ind_or_conf(struct osmo_fsm_inst *fi, uint32_t event,
{
uint8_t link_id;
uint8_t sapi;
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
OSMO_ASSERT(data);
link_id = *(uint8_t*)data;
@@ -1001,7 +1003,7 @@ static void lchan_fsm_wait_sapis_released_onenter(struct osmo_fsm_inst *fi, uint
{
int sapis;
int sapi;
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
for (sapi=0; sapi < ARRAY_SIZE(lchan->sapis); sapi++)
if (lchan->sapis[sapi])
@@ -1050,7 +1052,7 @@ static void lchan_fsm_wait_sapis_released(struct osmo_fsm_inst *fi, uint32_t eve
static void lchan_fsm_wait_rf_release_ack_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
int rc;
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
rc = rsl_tx_rf_chan_release(lchan);
if (rc)
LOG_LCHAN(lchan, LOGL_ERROR, "Failed to Tx RSL RF Channel Release: rc=%d %s\n",
@@ -1059,7 +1061,7 @@ static void lchan_fsm_wait_rf_release_ack_onenter(struct osmo_fsm_inst *fi, uint
static void lchan_fsm_wait_rf_release_ack(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
switch (event) {
case LCHAN_EV_RSL_RF_CHAN_REL_ACK:
@@ -1076,13 +1078,13 @@ static void lchan_fsm_wait_rf_release_ack(struct osmo_fsm_inst *fi, uint32_t eve
static void lchan_fsm_borken_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
lchan_reset(lchan);
}
static void lchan_fsm_borken(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
switch (event) {
case LCHAN_EV_RSL_CHAN_ACTIV_ACK:
@@ -1330,7 +1332,7 @@ static const struct value_string lchan_fsm_event_names[] = {
void lchan_fsm_allstate_action(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
switch (event) {
@@ -1358,7 +1360,7 @@ void lchan_fsm_allstate_action(struct osmo_fsm_inst *fi, uint32_t event, void *d
int lchan_fsm_timer_cb(struct osmo_fsm_inst *fi)
{
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
switch (fi->state) {
case LCHAN_ST_WAIT_BEFORE_RF_RELEASE:
@@ -1423,7 +1425,7 @@ void lchan_release(struct gsm_lchan *lchan, bool sacch_deact,
void lchan_fsm_cleanup(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause)
{
- GET_LCHAN();
+ struct gsm_lchan *lchan = lchan_fi_lchan(fi);
if (lchan->conn)
gscon_forget_lchan(lchan->conn, lchan);
lchan_reset(lchan);
diff --git a/src/osmo-bsc/mgw_endpoint_fsm.c b/src/osmo-bsc/mgw_endpoint_fsm.c
index 1095628ac..a61e67408 100644
--- a/src/osmo-bsc/mgw_endpoint_fsm.c
+++ b/src/osmo-bsc/mgw_endpoint_fsm.c
@@ -194,10 +194,13 @@ void mgw_endpoint_fsm_init(struct T_def *T_defs)
}
}
-/* From local var fi->priv, define local var mgewp. */
-#define GET_MGWEP() \
- struct mgw_endpoint *mgwep = fi->priv; \
- OSMO_ASSERT((fi)->fsm == &mgwep_fsm && (fi)->priv)
+struct mgw_endpoint *mgwep_fi_mgwep(struct osmo_fsm_inst *fi)
+{
+ OSMO_ASSERT(fi);
+ OSMO_ASSERT(fi->fsm == &mgwep_fsm);
+ OSMO_ASSERT(fi->priv);
+ return fi->priv;
+}
struct mgw_endpoint *mgw_endpoint_alloc(struct osmo_fsm_inst *parent, uint32_t parent_term_event,
struct mgcp_client *mgcp_client,
@@ -593,7 +596,7 @@ static void mgwep_fsm_check_state_chg_after_response(struct osmo_fsm_inst *fi)
{
int waiting_for_response;
int occupied;
- GET_MGWEP();
+ struct mgw_endpoint *mgwep = mgwep_fi_mgwep(fi);
mgwep_count(mgwep, &occupied, NULL, &waiting_for_response);
LOG_MGWEP(mgwep, LOGL_DEBUG, "CI in use: %d, waiting for response: %d", occupied, waiting_for_response);
@@ -617,7 +620,7 @@ static void mgwep_fsm_wait_mgw_response_onenter(struct osmo_fsm_inst *fi, uint32
{
int count = 0;
int i;
- GET_MGWEP();
+ struct mgw_endpoint *mgwep = mgwep_fi_mgwep(fi);
for (i = 0; i < ARRAY_SIZE(mgwep->ci); i++) {
count += send_verb(&mgwep->ci[i]);
@@ -631,7 +634,7 @@ static void mgwep_fsm_wait_mgw_response_onenter(struct osmo_fsm_inst *fi, uint32
static void mgwep_fsm_handle_ci_events(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
struct mgwep_ci *ci;
- GET_MGWEP();
+ struct mgw_endpoint *mgwep = mgwep_fi_mgwep(fi);
ci = mgwep_ci_for_event(mgwep, event);
if (ci) {
if (event == CI_EV_SUCCESS(ci))
@@ -644,7 +647,7 @@ static void mgwep_fsm_handle_ci_events(struct osmo_fsm_inst *fi, uint32_t event,
static void mgwep_fsm_in_use_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
int pending_not_sent;
- GET_MGWEP();
+ struct mgw_endpoint *mgwep = mgwep_fi_mgwep(fi);
mgwep_count(mgwep, NULL, &pending_not_sent, NULL);
if (pending_not_sent)
@@ -684,7 +687,7 @@ static const struct osmo_fsm_state mgwep_fsm_states[] = {
static int mgwep_fsm_timer_cb(struct osmo_fsm_inst *fi)
{
int i;
- GET_MGWEP();
+ struct mgw_endpoint *mgwep = mgwep_fi_mgwep(fi);
switch (fi->T) {
default:
diff --git a/src/osmo-bsc/timeslot_fsm.c b/src/osmo-bsc/timeslot_fsm.c
index 65f6889e6..e3085be07 100644
--- a/src/osmo-bsc/timeslot_fsm.c
+++ b/src/osmo-bsc/timeslot_fsm.c
@@ -37,13 +37,13 @@ enum ts_fsm_T {
T_CHAN_ACT_DEACT=23001,
};
-#define GET_TS(fi, TS) \
- struct gsm_bts_trx_ts *TS = fi->priv; \
- OSMO_ASSERT((fi)->fsm == &ts_fsm && (fi)->priv)
-
-#define GET_BTS_TS(fi, BTS, TS) \
- GET_TS(fi, TS); \
- struct gsm_bts *BTS = TS->trx->bts
+struct gsm_bts_trx_ts *ts_fi_ts(struct osmo_fsm_inst *fi)
+{
+ OSMO_ASSERT(fi);
+ OSMO_ASSERT(fi->fsm == &ts_fsm);
+ OSMO_ASSERT(fi->priv);
+ return fi->priv;
+}
static void ts_fsm_update_id(struct gsm_bts_trx_ts *ts)
{
@@ -152,7 +152,7 @@ static int ts_lchans_waiting(struct gsm_bts_trx_ts *ts)
static void ts_fsm_error(struct osmo_fsm_inst *fi, uint32_t state_chg, const char *fmt, ...)
{
- GET_TS(fi, ts);
+ struct gsm_bts_trx_ts *ts = ts_fi_ts(fi);
char *errmsg = NULL;
@@ -220,7 +220,8 @@ static void ts_setup_lchans(struct gsm_bts_trx_ts *ts)
static void ts_fsm_not_initialized(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- GET_BTS_TS(fi, bts, ts);
+ struct gsm_bts_trx_ts *ts = ts_fi_ts(fi);
+ struct gsm_bts *bts = ts->trx->bts;
switch (event) {
case TS_EV_OML_READY:
@@ -265,7 +266,8 @@ static void ts_fsm_not_initialized(struct osmo_fsm_inst *fi, uint32_t event, voi
static void ts_fsm_unused_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
- GET_BTS_TS(fi, bts, ts);
+ struct gsm_bts_trx_ts *ts = ts_fi_ts(fi);
+ struct gsm_bts *bts = ts->trx->bts;
/* We are entering the unused state. There must by definition not be any lchans waiting to be
* activated. */
@@ -302,7 +304,7 @@ static void ts_fsm_unused_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
static void ts_fsm_unused(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- GET_TS(fi, ts);
+ struct gsm_bts_trx_ts *ts = ts_fi_ts(fi);
switch (event) {
@@ -340,7 +342,7 @@ static inline void ts_fsm_pdch_deact(struct osmo_fsm_inst *fi)
static void ts_fsm_wait_pdch_act_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
int rc;
- GET_TS(fi, ts);
+ struct gsm_bts_trx_ts *ts = ts_fi_ts(fi);
rc = rsl_tx_dyn_ts_pdch_act_deact(ts, true);
@@ -351,7 +353,7 @@ static void ts_fsm_wait_pdch_act_onenter(struct osmo_fsm_inst *fi, uint32_t prev
static void ts_fsm_wait_pdch_act(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- GET_TS(fi, ts);
+ struct gsm_bts_trx_ts *ts = ts_fi_ts(fi);
switch (event) {
case TS_EV_PDCH_ACT_ACK:
@@ -398,7 +400,7 @@ static void ts_fsm_wait_pdch_act(struct osmo_fsm_inst *fi, uint32_t event, void
static void ts_fsm_pdch_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
int count;
- GET_TS(fi, ts);
+ struct gsm_bts_trx_ts *ts = ts_fi_ts(fi);
/* Set pchan = PDCH status, but double check. */
switch (ts->pchan_on_init) {
@@ -425,7 +427,7 @@ static void ts_fsm_pdch_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
static void ts_fsm_pdch(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- GET_TS(fi, ts);
+ struct gsm_bts_trx_ts *ts = ts_fi_ts(fi);
switch (event) {
case TS_EV_LCHAN_REQUESTED:
@@ -459,7 +461,7 @@ static void ts_fsm_pdch(struct osmo_fsm_inst *fi, uint32_t event, void *data)
static void ts_fsm_wait_pdch_deact_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
int rc;
- GET_TS(fi, ts);
+ struct gsm_bts_trx_ts *ts = ts_fi_ts(fi);
rc = rsl_tx_dyn_ts_pdch_act_deact(ts, false);
@@ -470,7 +472,7 @@ static void ts_fsm_wait_pdch_deact_onenter(struct osmo_fsm_inst *fi, uint32_t pr
static void ts_fsm_wait_pdch_deact(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- GET_TS(fi, ts);
+ struct gsm_bts_trx_ts *ts = ts_fi_ts(fi);
switch (event) {
case TS_EV_PDCH_DEACT_ACK:
@@ -530,7 +532,7 @@ static void ts_fsm_in_use_onenter(struct osmo_fsm_inst *fi, uint32_t prev_event)
{
int in_use;
struct gsm_lchan *lchan;
- GET_TS(fi, ts);
+ struct gsm_bts_trx_ts *ts = ts_fi_ts(fi);
/* After being in use, allow PDCH act again, if appropriate. */
ts->pdch_act_allowed = true;
@@ -551,7 +553,7 @@ static void ts_fsm_in_use_onenter(struct osmo_fsm_inst *fi, uint32_t prev_event)
static void ts_fsm_in_use(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- GET_TS(fi, ts);
+ struct gsm_bts_trx_ts *ts = ts_fi_ts(fi);
switch (event) {
case TS_EV_LCHAN_UNUSED:
if (!ts_count_active_lchans(ts))
@@ -623,7 +625,7 @@ static int ts_fsm_timer_cb(struct osmo_fsm_inst *fi)
static void ts_fsm_allstate(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- GET_TS(fi, ts);
+ struct gsm_bts_trx_ts *ts = ts_fi_ts(fi);
switch (event) {
case TS_EV_OML_DOWN:
if (fi->state != TS_ST_NOT_INITIALIZED)