Review at  https://gerrit.osmocom.org/4375

osmo-bsc MGCP and RESET FSMs: use distinct struct names

Make each file use unique struct names; e.g. not 'fsm' in both. They only exist
in the static context and it works fine, but the mad fsm-to-dot.py script
breaks with identical struct names. Can't hurt to have unique names either.

Change-Id: I986377a74ccd83ca3b52e7f058bbc9115f05f741
---
M src/osmo-bsc/osmo_bsc_mgcp.c
M src/osmo-bsc/osmo_bsc_reset.c
2 files changed, 27 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/75/4375/1

diff --git a/src/osmo-bsc/osmo_bsc_mgcp.c b/src/osmo-bsc/osmo_bsc_mgcp.c
index f2ab3c8..73dd12d 100644
--- a/src/osmo-bsc/osmo_bsc_mgcp.c
+++ b/src/osmo-bsc/osmo_bsc_mgcp.c
@@ -43,7 +43,7 @@
 
 extern struct gsm_network *bsc_gsmnet;
 
-enum fsm_states {
+enum fsm_bsc_mgcp_states {
        /* Initalization state to start the FSM */
        ST_CRCX_BTS,
 
@@ -66,7 +66,7 @@
        ST_HALT,
 };
 
-static const struct value_string fsm_state_names[] = {
+static const struct value_string fsm_bsc_mgcp_state_names[] = {
        {ST_CRCX_BTS, "ST_CRCX_BTS (send CRCX for BTS)"},
        {ST_ASSIGN_PROC, "ST_ASSIGN_PROC (conntinue assingment)"},
        {ST_MDCX_BTS, "ST_MDCX_BTS (send MDCX for BTS)"},
@@ -135,7 +135,7 @@
        OSMO_ASSERT(fi);
 
        LOGP(DMSC, LOGL_NOTICE, "MGCPGW: (%s) fsm-state: %s\n",
-            mgcp_ctx->name, get_value_string(fsm_state_names, fi->state));
+            mgcp_ctx->name, get_value_string(fsm_bsc_mgcp_state_names, 
fi->state));
 
        LOGP(DMGCP, LOGL_ERROR, "(%s) MGCPGW error proceeding request, graceful 
shutdown...\n", mgcp_ctx->name);
 
@@ -172,7 +172,7 @@
 
        LOGP(DMSC, LOGL_NOTICE,
             "MGCPGW: (%s) fsm-state: %s, fsm-event: %s\n",
-            mgcp_ctx->name, get_value_string(fsm_state_names, fi->state), 
get_value_string(fsm_evt_names, event));
+            mgcp_ctx->name, get_value_string(fsm_bsc_mgcp_state_names, 
fi->state), get_value_string(fsm_evt_names, event));
 
        rtp_endpoint = mgcp_client_next_endpoint(mgcp);
        mgcp_ctx->rtp_endpoint = rtp_endpoint;
@@ -256,7 +256,7 @@
 
        LOGP(DMSC, LOGL_NOTICE,
             "MGCPGW: (%s) fsm-state: %s, fsm-event: %s\n",
-            mgcp_ctx->name, get_value_string(fsm_state_names, fi->state), 
get_value_string(fsm_evt_names, event));
+            mgcp_ctx->name, get_value_string(fsm_bsc_mgcp_state_names, 
fi->state), get_value_string(fsm_evt_names, event));
 
        /* Bail on teardown */
        if (event == EV_TEARDOWN) {
@@ -303,7 +303,7 @@
 
        LOGP(DMSC, LOGL_NOTICE,
             "MGCPGW: (%s) fsm-state: %s, fsm-event: %s\n",
-            mgcp_ctx->name, get_value_string(fsm_state_names, fi->state), 
get_value_string(fsm_evt_names, event));
+            mgcp_ctx->name, get_value_string(fsm_bsc_mgcp_state_names, 
fi->state), get_value_string(fsm_evt_names, event));
 
        /* Bail on teardown */
        if (event == EV_TEARDOWN) {
@@ -422,7 +422,7 @@
 
        LOGP(DMSC, LOGL_NOTICE,
             "MGCPGW: (%s) fsm-state: %s, fsm-event: %s\n",
-            mgcp_ctx->name, get_value_string(fsm_state_names, fi->state), 
get_value_string(fsm_evt_names, event));
+            mgcp_ctx->name, get_value_string(fsm_bsc_mgcp_state_names, 
fi->state), get_value_string(fsm_evt_names, event));
 
        rtp_endpoint = mgcp_ctx->rtp_endpoint;
        call_id = conn->conn_id;
@@ -524,7 +524,7 @@
 
        LOGP(DMSC, LOGL_NOTICE,
             "MGCPGW: (%s) fsm-state: %s, fsm-event: %s\n",
-            mgcp_ctx->name, get_value_string(fsm_state_names, fi->state), 
get_value_string(fsm_evt_names, event));
+            mgcp_ctx->name, get_value_string(fsm_bsc_mgcp_state_names, 
fi->state), get_value_string(fsm_evt_names, event));
 
        /* Bail on teardown */
        if (event == EV_TEARDOWN) {
@@ -570,7 +570,7 @@
 
        LOGP(DMSC, LOGL_NOTICE,
             "MGCPGW: (%s) fsm-state: %s, fsm-event: %s\n",
-            mgcp_ctx->name, get_value_string(fsm_state_names, fi->state), 
get_value_string(fsm_evt_names, event));
+            mgcp_ctx->name, get_value_string(fsm_bsc_mgcp_state_names, 
fi->state), get_value_string(fsm_evt_names, event));
 
        rtp_endpoint = mgcp_ctx->rtp_endpoint;
        call_id = conn->conn_id;
@@ -638,11 +638,11 @@
 
        LOGP(DMSC, LOGL_NOTICE,
             "MGCPGW: (%s) fsm-state: %s, fsm-event: %s\n",
-            mgcp_ctx->name, get_value_string(fsm_state_names, fi->state), 
get_value_string(fsm_evt_names, event));
+            mgcp_ctx->name, get_value_string(fsm_bsc_mgcp_state_names, 
fi->state), get_value_string(fsm_evt_names, event));
 
        LOGP(DMGCP, LOGL_NOTICE,
             "MGCPGW: (%s) timeout (T%i) in state %s, state machine halted\n",
-            mgcp_ctx->name, fi->T, get_value_string(fsm_state_names, 
fi->state));
+            mgcp_ctx->name, fi->T, get_value_string(fsm_bsc_mgcp_state_names, 
fi->state));
 
        /* Send pending sigtran message */
        if (mgcp_ctx->resp) {
@@ -672,7 +672,7 @@
 
        LOGP(DMGCP, LOGL_ERROR,
             "MGCPGW: (%s) timeout (T%i) in state %s, attempting graceful 
teardown...\n",
-            mgcp_ctx->name, fi->T, get_value_string(fsm_state_names, 
fi->state));
+            mgcp_ctx->name, fi->T, get_value_string(fsm_bsc_mgcp_state_names, 
fi->state));
 
        /* Ensure that no sigtran response, is present. Otherwiese we might try
         * to send a sigtran response when the sccp connection is already 
freed. */
@@ -706,7 +706,7 @@
        return 0;
 }
 
-static struct osmo_fsm_state fsm_states[] = {
+static struct osmo_fsm_state fsm_bsc_mgcp_states[] = {
 
        /* Startup state machine, send CRCX to BTS. */
        [ST_CRCX_BTS] = {
@@ -776,10 +776,10 @@
 };
 
 /* State machine definition */
-static struct osmo_fsm fsm = {
+static struct osmo_fsm fsm_bsc_mgcp = {
        .name = "FSM MGCP",
-       .states = fsm_states,
-       .num_states = ARRAY_SIZE(fsm_states),
+       .states = fsm_bsc_mgcp_states,
+       .num_states = ARRAY_SIZE(fsm_bsc_mgcp_states),
        .log_subsys = DMGCP,
        .timer_cb = fsm_timeout_cb,
 };
@@ -803,15 +803,15 @@
        OSMO_ASSERT(conn);
 
        /* Register the fsm description (if not already done) */
-       if (osmo_fsm_find_by_name(fsm.name) != &fsm)
-               osmo_fsm_register(&fsm);
+       if (osmo_fsm_find_by_name(fsm_bsc_mgcp.name) != &fsm_bsc_mgcp)
+               osmo_fsm_register(&fsm_bsc_mgcp);
 
        /* Allocate and configure a new fsm instance */
        mgcp_ctx = talloc_zero(ctx, struct mgcp_ctx);
        OSMO_ASSERT(mgcp_ctx);
 
        snprintf(mgcp_ctx->name, sizeof(mgcp_ctx->name), "MGCP FSM, id=%i", 
conn->conn_id);
-       mgcp_ctx->fsm = osmo_fsm_inst_alloc(&fsm, NULL, ctx, LOGL_DEBUG, "FSM 
MGCP INST");
+       mgcp_ctx->fsm = osmo_fsm_inst_alloc(&fsm_bsc_mgcp, NULL, ctx, 
LOGL_DEBUG, "FSM MGCP INST");
        OSMO_ASSERT(mgcp_ctx->fsm);
        mgcp_ctx->fsm->priv = mgcp_ctx;
        LOGP(DMGCP, LOGL_NOTICE, "MGCPGW: (%s) MGCPGW handler fsm created\n", 
mgcp_ctx->name);
diff --git a/src/osmo-bsc/osmo_bsc_reset.c b/src/osmo-bsc/osmo_bsc_reset.c
index d28f548..ba27645 100644
--- a/src/osmo-bsc/osmo_bsc_reset.c
+++ b/src/osmo-bsc/osmo_bsc_reset.c
@@ -38,7 +38,7 @@
        ST_CONN,                /* We have a confirmed connection to the MSC */
 };
 
-static const struct value_string fsm_state_names[] = {
+static const struct value_string fsm_bsc_reset_state_names[] = {
        {ST_DISC, "ST_DISC (disconnected)"},
        {ST_CONN, "ST_CONN (connected)"},
        {0, NULL},
@@ -50,7 +50,7 @@
        EV_N_CONNECT,           /* made a successful connection */
 };
 
-static const struct value_string fsm_evt_names[] = {
+static const struct value_string fsm_bsc_reset_evt_names[] = {
        {EV_RESET_ACK, "EV_RESET_ACK"},
        {EV_N_DISCONNECT, "EV_N_DISCONNECT"},
        {EV_N_CONNECT, "EV_N_CONNECT"},
@@ -63,7 +63,7 @@
        struct bsc_msc_data *msc = (struct bsc_msc_data *)data;
 
        LOGP(DMSC, LOGL_NOTICE, "fsm-state (msc-reset): %s, fsm-event: %s, MSC 
No.: %i\n",
-            get_value_string(fsm_state_names, ST_DISC), 
get_value_string(fsm_evt_names, event), msc->nr);
+            get_value_string(fsm_bsc_reset_state_names, ST_DISC), 
get_value_string(fsm_bsc_reset_evt_names, event), msc->nr);
        msc->msc_con->msc_conn_loss_count = 0;
        osmo_fsm_inst_state_chg(fi, ST_CONN, 0, 0);
 }
@@ -74,7 +74,7 @@
        struct bsc_msc_data *msc = (struct bsc_msc_data *)data;
 
        LOGP(DMSC, LOGL_NOTICE, "fsm-state (msc-reset): %s, fsm-event: %s, MSC 
No.: %i\n",
-            get_value_string(fsm_state_names, ST_CONN), 
get_value_string(fsm_evt_names, event), msc->nr);
+            get_value_string(fsm_bsc_reset_state_names, ST_CONN), 
get_value_string(fsm_bsc_reset_evt_names, event), msc->nr);
 
        OSMO_ASSERT(msc);
 
@@ -98,7 +98,7 @@
        struct bsc_msc_data *msc = (struct bsc_msc_data *)fi->priv;
 
        LOGP(DMSC, LOGL_NOTICE, "reset-ack timeout (T%i) in state %s, MSC No.: 
%i, resending...\n", fi->T,
-            get_value_string(fsm_state_names, fi->state), msc->nr);
+            get_value_string(fsm_bsc_reset_state_names, fi->state), msc->nr);
 
        osmo_bsc_sigtran_reset(msc);
        osmo_bsc_sigtran_tx_reset(msc);
@@ -123,7 +123,7 @@
 };
 
 /* State machine definition */
-static struct osmo_fsm fsm = {
+static struct osmo_fsm fsm_bsc_reset = {
        .name = "FSM RESET",
        .states = fsm_states,
        .num_states = ARRAY_SIZE(fsm_states),
@@ -137,8 +137,8 @@
        OSMO_ASSERT(msc);
        OSMO_ASSERT(msc->msc_con);
 
-       osmo_fsm_register(&fsm);
-       msc->msc_con->fsm_reset = osmo_fsm_inst_alloc(&fsm, NULL, NULL, 
LOGL_DEBUG, "FSM RESET INST");
+       osmo_fsm_register(&fsm_bsc_reset);
+       msc->msc_con->fsm_reset = osmo_fsm_inst_alloc(&fsm_bsc_reset, NULL, 
NULL, LOGL_DEBUG, "FSM RESET INST");
        OSMO_ASSERT(msc->msc_con->fsm_reset);
 
        msc->msc_con->fsm_reset->priv = msc;

-- 
To view, visit https://gerrit.osmocom.org/4375
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I986377a74ccd83ca3b52e7f058bbc9115f05f741
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofm...@sysmocom.de>

Reply via email to