Split event list for smscb_message_fsm and smscb_peer_fsm

It really doesn't make sense to share the event list betwen those for
several reasons.
First, because ech of those FSM relate to different things:
* smscb_message_fsm: Handling/scheduling of 1 smscb towards all peers
* smscb_peer_fsm: Handling/scheduling of 1 smscb towards 1 peer.

The former has higher level interface used by the REST
API, plus some mid level interface used by smscb_peer_fsm.
The later has a mid level interface used by smscb_message_fsm to
interact, and a lower level interface used by the SBcAP/CBSP links to
talk to.

Furthermore, this makes it a lot easier understanding which events are
sent from one to another FSM.

Change-Id: I909474d1ff4ec7ed20aff0981da47074397df6cb
This commit is contained in:
Pau Espin Pedrol
2022-07-27 20:26:41 +02:00
parent cb99991127
commit c190939f0c
8 changed files with 197 additions and 179 deletions

View File

@@ -13,4 +13,5 @@ noinst_HEADERS = \
sbcap_link_fsm.h \ sbcap_link_fsm.h \
rest_it_op.h \ rest_it_op.h \
smscb_message_fsm.h \ smscb_message_fsm.h \
smscb_peer_fsm.h \
$(NULL) $(NULL)

View File

@@ -3,36 +3,28 @@
#include <stdint.h> #include <stdint.h>
#include <osmocom/core/fsm.h> #include <osmocom/core/fsm.h>
enum smscb_fsm_event { enum smscb_message_fsm_event {
SMSCB_E_CHILD_DIED, SMSCB_MSG_E_CHILD_DIED,
/* create a message (from REST) */ /* create a message (from REST) */
SMSCB_E_CREATE, SMSCB_MSG_E_CREATE,
/* replace a message (from REST) */ /* replace a message (from REST) */
SMSCB_E_REPLACE, SMSCB_MSG_E_REPLACE,
/* get status of a message (from REST) */ /* get status of a message (from REST) */
SMSCB_E_STATUS, SMSCB_MSG_E_STATUS,
/* delete a message (from REST) */ /* delete a message (from REST) */
SMSCB_E_DELETE, SMSCB_MSG_E_DELETE,
/* CBSP peer confirms write */ /* peer confirms write */
SMSCB_E_CBSP_WRITE_ACK, SMSCB_MSG_E_WRITE_ACK,
SMSCB_E_CBSP_WRITE_NACK, SMSCB_MSG_E_WRITE_NACK,
/* CBSP peer confirms replace */ /* peer confirms replace */
SMSCB_E_CBSP_REPLACE_ACK, SMSCB_MSG_E_REPLACE_ACK,
SMSCB_E_CBSP_REPLACE_NACK, SMSCB_MSG_E_REPLACE_NACK,
/* CBSP peer confirms delete */ /* peer confirms delete */
SMSCB_E_CBSP_DELETE_ACK, SMSCB_MSG_E_DELETE_ACK,
SMSCB_E_CBSP_DELETE_NACK, SMSCB_MSG_E_DELETE_NACK,
/* CBSP peer confirms status query */ /* peer confirms status query */
SMSCB_E_CBSP_STATUS_ACK, SMSCB_MSG_E_STATUS_ACK,
SMSCB_E_CBSP_STATUS_NACK, SMSCB_MSG_E_STATUS_NACK
/* SBc-AP peer confirms write */
SMSCB_E_SBCAP_WRITE_ACK,
SMSCB_E_SBCAP_WRITE_NACK,
/* SBc-AP peer confirms delete */
SMSCB_E_SBCAP_DELETE_ACK,
SMSCB_E_SBCAP_DELETE_NACK,
/* SBc-AP peer sends Write Replace Warning Indication to us */
SMSCB_E_SBCAP_WRITE_IND,
}; };
enum smscb_fsm_state { enum smscb_fsm_state {
@@ -58,4 +50,4 @@ enum smscb_p_fsm_timer {
T_WAIT_DELETE_ACK, T_WAIT_DELETE_ACK,
}; };
extern const struct value_string smscb_fsm_event_names[]; extern const struct value_string smscb_message_fsm_event_names[];

View File

@@ -0,0 +1,37 @@
#pragma once
#include <stdint.h>
#include <osmocom/core/fsm.h>
enum smscb_peer_fsm_event {
/* create a message (from REST) */
SMSCB_PEER_E_CREATE,
/* replace a message (from REST) */
SMSCB_PEER_E_REPLACE,
/* get status of a message (from REST) */
SMSCB_PEER_E_STATUS,
/* delete a message (from REST) */
SMSCB_PEER_E_DELETE,
/* CBSP peer confirms write */
SMSCB_PEER_E_CBSP_WRITE_ACK,
SMSCB_PEER_E_CBSP_WRITE_NACK,
/* CBSP peer confirms replace */
SMSCB_PEER_E_CBSP_REPLACE_ACK,
SMSCB_PEER_E_CBSP_REPLACE_NACK,
/* CBSP peer confirms delete */
SMSCB_PEER_E_CBSP_DELETE_ACK,
SMSCB_PEER_E_CBSP_DELETE_NACK,
/* CBSP peer confirms status query */
SMSCB_PEER_E_CBSP_STATUS_ACK,
SMSCB_PEER_E_CBSP_STATUS_NACK,
/* SBc-AP peer confirms write */
SMSCB_PEER_E_SBCAP_WRITE_ACK,
SMSCB_PEER_E_SBCAP_WRITE_NACK,
/* SBc-AP peer confirms delete */
SMSCB_PEER_E_SBCAP_DELETE_ACK,
SMSCB_PEER_E_SBCAP_DELETE_NACK,
/* SBc-AP peer sends Write Replace Warning Indication to us */
SMSCB_PEER_E_SBCAP_WRITE_IND,
};
extern const struct value_string smscb_peer_fsm_event_names[];

View File

@@ -130,7 +130,7 @@ int cbc_message_new(const struct cbc_message *orig, struct rest_it_op *op)
} }
/* kick off the state machine[s] */ /* kick off the state machine[s] */
if (osmo_fsm_inst_dispatch(cbcmsg->fi, SMSCB_E_CREATE, op) < 0) { if (osmo_fsm_inst_dispatch(cbcmsg->fi, SMSCB_MSG_E_CREATE, op) < 0) {
rest_it_op_set_http_result(op, 500, "Illegal FSM event"); rest_it_op_set_http_result(op, 500, "Illegal FSM event");
rest_it_op_complete(op); rest_it_op_complete(op);
} }
@@ -142,7 +142,7 @@ int cbc_message_new(const struct cbc_message *orig, struct rest_it_op *op)
void cbc_message_delete(struct cbc_message *cbcmsg, struct rest_it_op *op) void cbc_message_delete(struct cbc_message *cbcmsg, struct rest_it_op *op)
{ {
if (osmo_fsm_inst_dispatch(cbcmsg->fi, SMSCB_E_DELETE, op) < 0) { if (osmo_fsm_inst_dispatch(cbcmsg->fi, SMSCB_MSG_E_DELETE, op) < 0) {
rest_it_op_set_http_result(op, 500, "Illegal FSM event"); rest_it_op_set_http_result(op, 500, "Illegal FSM event");
rest_it_op_complete(op); rest_it_op_complete(op);
} }

View File

@@ -27,7 +27,7 @@
#include <osmocom/cbc/cbsp_link.h> #include <osmocom/cbc/cbsp_link.h>
#include <osmocom/cbc/cbsp_link_fsm.h> #include <osmocom/cbc/cbsp_link_fsm.h>
#include <osmocom/cbc/debug.h> #include <osmocom/cbc/debug.h>
#include <osmocom/cbc/smscb_message_fsm.h> #include <osmocom/cbc/smscb_peer_fsm.h>
#define S(x) (1 << (x)) #define S(x) (1 << (x))
@@ -339,22 +339,22 @@ int cbc_cbsp_link_rx_cb(struct cbc_cbsp_link *link, struct osmo_cbsp_decoded *de
switch (dec->msg_type) { switch (dec->msg_type) {
case CBSP_MSGT_WRITE_REPLACE_COMPL: case CBSP_MSGT_WRITE_REPLACE_COMPL:
if (dec->u.write_replace_compl.old_serial_nr) if (dec->u.write_replace_compl.old_serial_nr)
return osmo_fsm_inst_dispatch(mp->fi, SMSCB_E_CBSP_REPLACE_ACK, dec); return osmo_fsm_inst_dispatch(mp->fi, SMSCB_PEER_E_CBSP_REPLACE_ACK, dec);
else else
return osmo_fsm_inst_dispatch(mp->fi, SMSCB_E_CBSP_WRITE_ACK, dec); return osmo_fsm_inst_dispatch(mp->fi, SMSCB_PEER_E_CBSP_WRITE_ACK, dec);
case CBSP_MSGT_WRITE_REPLACE_FAIL: case CBSP_MSGT_WRITE_REPLACE_FAIL:
if (dec->u.write_replace_fail.old_serial_nr) if (dec->u.write_replace_fail.old_serial_nr)
return osmo_fsm_inst_dispatch(mp->fi, SMSCB_E_CBSP_REPLACE_NACK, dec); return osmo_fsm_inst_dispatch(mp->fi, SMSCB_PEER_E_CBSP_REPLACE_NACK, dec);
else else
return osmo_fsm_inst_dispatch(mp->fi, SMSCB_E_CBSP_WRITE_NACK, dec); return osmo_fsm_inst_dispatch(mp->fi, SMSCB_PEER_E_CBSP_WRITE_NACK, dec);
case CBSP_MSGT_KILL_COMPL: case CBSP_MSGT_KILL_COMPL:
return osmo_fsm_inst_dispatch(mp->fi, SMSCB_E_CBSP_DELETE_ACK, dec); return osmo_fsm_inst_dispatch(mp->fi, SMSCB_PEER_E_CBSP_DELETE_ACK, dec);
case CBSP_MSGT_KILL_FAIL: case CBSP_MSGT_KILL_FAIL:
return osmo_fsm_inst_dispatch(mp->fi, SMSCB_E_CBSP_DELETE_NACK, dec); return osmo_fsm_inst_dispatch(mp->fi, SMSCB_PEER_E_CBSP_DELETE_NACK, dec);
case CBSP_MSGT_MSG_STATUS_QUERY_COMPL: case CBSP_MSGT_MSG_STATUS_QUERY_COMPL:
return osmo_fsm_inst_dispatch(mp->fi, SMSCB_E_CBSP_STATUS_ACK, dec); return osmo_fsm_inst_dispatch(mp->fi, SMSCB_PEER_E_CBSP_STATUS_ACK, dec);
case CBSP_MSGT_MSG_STATUS_QUERY_FAIL: case CBSP_MSGT_MSG_STATUS_QUERY_FAIL:
return osmo_fsm_inst_dispatch(mp->fi, SMSCB_E_CBSP_STATUS_NACK, dec); return osmo_fsm_inst_dispatch(mp->fi, SMSCB_PEER_E_CBSP_STATUS_NACK, dec);
default: default:
LOGPCC(link, LOGL_ERROR, "unknown message %s\n", LOGPCC(link, LOGL_ERROR, "unknown message %s\n",
get_value_string(cbsp_msg_type_names, dec->msg_type)); get_value_string(cbsp_msg_type_names, dec->msg_type));

View File

@@ -31,7 +31,7 @@
#include <osmocom/cbc/sbcap_msg.h> #include <osmocom/cbc/sbcap_msg.h>
#include <osmocom/cbc/debug.h> #include <osmocom/cbc/debug.h>
#include <osmocom/cbc/cbc_peer.h> #include <osmocom/cbc/cbc_peer.h>
#include <osmocom/cbc/smscb_message_fsm.h> #include <osmocom/cbc/smscb_peer_fsm.h>
#define S(x) (1 << (x)) #define S(x) (1 << (x))
@@ -249,7 +249,7 @@ static int cbc_sbcap_link_rx_write_replace_warn_resp(struct cbc_sbcap_link *link
A_SEQUENCE_OF(void) *as_pdu; A_SEQUENCE_OF(void) *as_pdu;
SBcAP_Write_Replace_Warning_Response_IEs_t *ie; SBcAP_Write_Replace_Warning_Response_IEs_t *ie;
SBcAP_SBC_AP_PDU_t *err_ind_pdu; SBcAP_SBC_AP_PDU_t *err_ind_pdu;
int ev = SMSCB_E_SBCAP_WRITE_ACK; int ev = SMSCB_PEER_E_SBCAP_WRITE_ACK;
as_pdu = (void *)&pdu->choice.successfulOutcome.value.choice.Write_Replace_Warning_Response.protocolIEs.list; as_pdu = (void *)&pdu->choice.successfulOutcome.value.choice.Write_Replace_Warning_Response.protocolIEs.list;
@@ -257,9 +257,9 @@ static int cbc_sbcap_link_rx_write_replace_warn_resp(struct cbc_sbcap_link *link
ie = sbcap_as_find_ie(as_pdu, 1); ie = sbcap_as_find_ie(as_pdu, 1);
if (ie) { if (ie) {
if (ie->value.choice.Cause != SBcAP_Cause_message_accepted) if (ie->value.choice.Cause != SBcAP_Cause_message_accepted)
ev = SMSCB_E_SBCAP_WRITE_NACK; ev = SMSCB_PEER_E_SBCAP_WRITE_NACK;
} else { /* This shouldn't happen, the IE is Mandatory... */ } else { /* This shouldn't happen, the IE is Mandatory... */
ev = SMSCB_E_SBCAP_WRITE_NACK; ev = SMSCB_PEER_E_SBCAP_WRITE_NACK;
err_ind_pdu = sbcap_gen_error_ind(link, err_ind_pdu = sbcap_gen_error_ind(link,
SBcAP_Cause_missing_mandatory_element, pdu); SBcAP_Cause_missing_mandatory_element, pdu);
if (err_ind_pdu) if (err_ind_pdu)
@@ -362,7 +362,7 @@ int cbc_sbcap_link_rx_cb(struct cbc_sbcap_link *link, SBcAP_SBC_AP_PDU_t *pdu)
case SBcAP_SBC_AP_PDU_PR_initiatingMessage: case SBcAP_SBC_AP_PDU_PR_initiatingMessage:
switch (pdu->choice.initiatingMessage.procedureCode) { switch (pdu->choice.initiatingMessage.procedureCode) {
case SBcAP_ProcedureId_Write_Replace_Warning_Indication: case SBcAP_ProcedureId_Write_Replace_Warning_Indication:
return osmo_fsm_inst_dispatch(mp->fi, SMSCB_E_SBCAP_WRITE_IND, pdu); return osmo_fsm_inst_dispatch(mp->fi, SMSCB_PEER_E_SBCAP_WRITE_IND, pdu);
default: default:
break; break;
} }
@@ -371,11 +371,11 @@ int cbc_sbcap_link_rx_cb(struct cbc_sbcap_link *link, SBcAP_SBC_AP_PDU_t *pdu)
switch (pdu->choice.successfulOutcome.procedureCode) { switch (pdu->choice.successfulOutcome.procedureCode) {
case SBcAP_ProcedureId_Write_Replace_Warning: case SBcAP_ProcedureId_Write_Replace_Warning:
//if (dec->u.write_replace_compl.old_serial_nr) //if (dec->u.write_replace_compl.old_serial_nr)
// return osmo_fsm_inst_dispatch(mp->fi, SMSCB_E_SBcAP_REPLACE_ACK, dec); // return osmo_fsm_inst_dispatch(mp->fi, SMSCB_PEER_E_SBcAP_REPLACE_ACK, dec);
//else //else
return cbc_sbcap_link_rx_write_replace_warn_resp(link, mp, pdu); return cbc_sbcap_link_rx_write_replace_warn_resp(link, mp, pdu);
case SBcAP_ProcedureId_Stop_Warning: case SBcAP_ProcedureId_Stop_Warning:
return osmo_fsm_inst_dispatch(mp->fi, SMSCB_E_SBCAP_DELETE_ACK, pdu); return osmo_fsm_inst_dispatch(mp->fi, SMSCB_PEER_E_SBCAP_DELETE_ACK, pdu);
default: default:
break; break;
} }
@@ -383,7 +383,7 @@ int cbc_sbcap_link_rx_cb(struct cbc_sbcap_link *link, SBcAP_SBC_AP_PDU_t *pdu)
case SBcAP_SBC_AP_PDU_PR_unsuccessfulOutcome: case SBcAP_SBC_AP_PDU_PR_unsuccessfulOutcome:
switch (pdu->choice.unsuccessfulOutcome.procedureCode) { switch (pdu->choice.unsuccessfulOutcome.procedureCode) {
case SBcAP_ProcedureId_Stop_Warning: case SBcAP_ProcedureId_Stop_Warning:
return osmo_fsm_inst_dispatch(mp->fi, SMSCB_E_SBCAP_DELETE_NACK, pdu); return osmo_fsm_inst_dispatch(mp->fi, SMSCB_PEER_E_SBCAP_DELETE_NACK, pdu);
default: default:
break; break;
} }

View File

@@ -35,20 +35,38 @@
#include <osmocom/cbc/debug.h> #include <osmocom/cbc/debug.h>
#include <osmocom/cbc/rest_it_op.h> #include <osmocom/cbc/rest_it_op.h>
#include <osmocom/cbc/smscb_message_fsm.h> #include <osmocom/cbc/smscb_message_fsm.h>
#include <osmocom/cbc/smscb_peer_fsm.h>
#define S(x) (1 << (x)) #define S(x) (1 << (x))
const struct value_string smscb_message_fsm_event_names[] = {
{ SMSCB_MSG_E_CHILD_DIED, "CHILD_DIED" },
{ SMSCB_MSG_E_CREATE, "CREATE" },
{ SMSCB_MSG_E_REPLACE, "REPLACE" },
{ SMSCB_MSG_E_STATUS, "STATUS" },
{ SMSCB_MSG_E_DELETE, "DELETE" },
{ SMSCB_MSG_E_WRITE_ACK, "WRITE_ACK" },
{ SMSCB_MSG_E_WRITE_NACK, "WRITE_NACK" },
{ SMSCB_MSG_E_REPLACE_ACK, "REPLACE_ACK" },
{ SMSCB_MSG_E_REPLACE_NACK, "REPLACE_NACK" },
{ SMSCB_MSG_E_DELETE_ACK, "DELETE_ACK" },
{ SMSCB_MSG_E_DELETE_NACK, "DELETE_NACK" },
{ SMSCB_MSG_E_STATUS_ACK, "STATUS_ACK" },
{ SMSCB_MSG_E_STATUS_NACK, "STATUS_NACK" },
{ 0, NULL }
};
static void smscb_fsm_init(struct osmo_fsm_inst *fi, uint32_t event, void *data) static void smscb_fsm_init(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{ {
struct cbc_message *cbcmsg = fi->priv; struct cbc_message *cbcmsg = fi->priv;
switch (event) { switch (event) {
case SMSCB_E_CREATE: case SMSCB_MSG_E_CREATE:
OSMO_ASSERT(!cbcmsg->it_op); OSMO_ASSERT(!cbcmsg->it_op);
cbcmsg->it_op = data; cbcmsg->it_op = data;
osmo_fsm_inst_state_chg(fi, SMSCB_S_WAIT_WRITE_ACK, 15, T_WAIT_WRITE_ACK); osmo_fsm_inst_state_chg(fi, SMSCB_S_WAIT_WRITE_ACK, 15, T_WAIT_WRITE_ACK);
/* forward this event to all child FSMs (i.e. all smscb_message_peer) */ /* forward this event to all child FSMs (i.e. all smscb_message_peer) */
osmo_fsm_inst_broadcast_children(fi, SMSCB_E_CREATE, NULL); osmo_fsm_inst_broadcast_children(fi, SMSCB_PEER_E_CREATE, NULL);
break; break;
default: default:
OSMO_ASSERT(0); OSMO_ASSERT(0);
@@ -61,10 +79,8 @@ static void smscb_fsm_wait_write_ack(struct osmo_fsm_inst *fi, uint32_t event, v
struct osmo_fsm_inst *peer_fi; struct osmo_fsm_inst *peer_fi;
switch (event) { switch (event) {
case SMSCB_E_CBSP_WRITE_ACK: case SMSCB_MSG_E_WRITE_ACK:
case SMSCB_E_CBSP_WRITE_NACK: case SMSCB_MSG_E_WRITE_NACK:
case SMSCB_E_SBCAP_WRITE_ACK:
case SMSCB_E_SBCAP_WRITE_NACK:
/* check if any per-peer children have not yet received the ACK or /* check if any per-peer children have not yet received the ACK or
* timed out */ * timed out */
llist_for_each_entry(peer_fi, &fi->proc.children, proc.child) { llist_for_each_entry(peer_fi, &fi->proc.children, proc.child) {
@@ -92,26 +108,26 @@ static void smscb_fsm_active(struct osmo_fsm_inst *fi, uint32_t event, void *dat
struct cbc_message *cbcmsg = fi->priv; struct cbc_message *cbcmsg = fi->priv;
switch (event) { switch (event) {
case SMSCB_E_REPLACE: case SMSCB_MSG_E_REPLACE:
OSMO_ASSERT(!cbcmsg->it_op); OSMO_ASSERT(!cbcmsg->it_op);
cbcmsg->it_op = data; cbcmsg->it_op = data;
osmo_fsm_inst_state_chg(fi, SMSCB_S_WAIT_REPLACE_ACK, 15, T_WAIT_REPLACE_ACK); osmo_fsm_inst_state_chg(fi, SMSCB_S_WAIT_REPLACE_ACK, 15, T_WAIT_REPLACE_ACK);
/* forward this event to all child FSMs (i.e. all smscb_message_peer) */ /* forward this event to all child FSMs (i.e. all smscb_message_peer) */
osmo_fsm_inst_broadcast_children(fi, SMSCB_E_REPLACE, data); osmo_fsm_inst_broadcast_children(fi, SMSCB_PEER_E_REPLACE, data);
break; break;
case SMSCB_E_STATUS: case SMSCB_MSG_E_STATUS:
OSMO_ASSERT(!cbcmsg->it_op); OSMO_ASSERT(!cbcmsg->it_op);
cbcmsg->it_op = data; cbcmsg->it_op = data;
osmo_fsm_inst_state_chg(fi, SMSCB_S_WAIT_STATUS_ACK, 15, T_WAIT_STATUS_ACK); osmo_fsm_inst_state_chg(fi, SMSCB_S_WAIT_STATUS_ACK, 15, T_WAIT_STATUS_ACK);
/* forward this event to all child FSMs (i.e. all smscb_message_peer) */ /* forward this event to all child FSMs (i.e. all smscb_message_peer) */
osmo_fsm_inst_broadcast_children(fi, SMSCB_E_STATUS, data); osmo_fsm_inst_broadcast_children(fi, SMSCB_PEER_E_STATUS, data);
break; break;
case SMSCB_E_DELETE: case SMSCB_MSG_E_DELETE:
OSMO_ASSERT(!cbcmsg->it_op); OSMO_ASSERT(!cbcmsg->it_op);
cbcmsg->it_op = data; cbcmsg->it_op = data;
osmo_fsm_inst_state_chg(fi, SMSCB_S_WAIT_DELETE_ACK, 15, T_WAIT_DELETE_ACK); osmo_fsm_inst_state_chg(fi, SMSCB_S_WAIT_DELETE_ACK, 15, T_WAIT_DELETE_ACK);
/* forward this event to all child FSMs (i.e. all smscb_message_peer) */ /* forward this event to all child FSMs (i.e. all smscb_message_peer) */
osmo_fsm_inst_broadcast_children(fi, SMSCB_E_DELETE, data); osmo_fsm_inst_broadcast_children(fi, SMSCB_PEER_E_DELETE, data);
break; break;
default: default:
OSMO_ASSERT(0); OSMO_ASSERT(0);
@@ -124,8 +140,8 @@ static void smscb_fsm_wait_replace_ack(struct osmo_fsm_inst *fi, uint32_t event,
struct osmo_fsm_inst *peer_fi; struct osmo_fsm_inst *peer_fi;
switch (event) { switch (event) {
case SMSCB_E_CBSP_REPLACE_ACK: case SMSCB_MSG_E_REPLACE_ACK:
case SMSCB_E_CBSP_REPLACE_NACK: case SMSCB_MSG_E_REPLACE_NACK:
llist_for_each_entry(peer_fi, &fi->proc.children, proc.child) { llist_for_each_entry(peer_fi, &fi->proc.children, proc.child) {
if (peer_fi->state == SMSCB_S_WAIT_REPLACE_ACK) if (peer_fi->state == SMSCB_S_WAIT_REPLACE_ACK)
return; return;
@@ -152,8 +168,8 @@ static void smscb_fsm_wait_status_ack(struct osmo_fsm_inst *fi, uint32_t event,
struct osmo_fsm_inst *peer_fi; struct osmo_fsm_inst *peer_fi;
switch (event) { switch (event) {
case SMSCB_E_CBSP_STATUS_ACK: case SMSCB_MSG_E_STATUS_ACK:
case SMSCB_E_CBSP_STATUS_NACK: case SMSCB_MSG_E_STATUS_NACK:
llist_for_each_entry(peer_fi, &fi->proc.children, proc.child) { llist_for_each_entry(peer_fi, &fi->proc.children, proc.child) {
if (peer_fi->state == SMSCB_S_WAIT_STATUS_ACK) if (peer_fi->state == SMSCB_S_WAIT_STATUS_ACK)
return; return;
@@ -180,10 +196,8 @@ static void smscb_fsm_wait_delete_ack(struct osmo_fsm_inst *fi, uint32_t event,
struct osmo_fsm_inst *peer_fi; struct osmo_fsm_inst *peer_fi;
switch (event) { switch (event) {
case SMSCB_E_CBSP_DELETE_ACK: case SMSCB_MSG_E_DELETE_ACK:
case SMSCB_E_CBSP_DELETE_NACK: case SMSCB_MSG_E_DELETE_NACK:
case SMSCB_E_SBCAP_DELETE_ACK:
case SMSCB_E_SBCAP_DELETE_NACK:
llist_for_each_entry(peer_fi, &fi->proc.children, proc.child) { llist_for_each_entry(peer_fi, &fi->proc.children, proc.child) {
if (peer_fi->state != SMSCB_S_DELETED) if (peer_fi->state != SMSCB_S_DELETED)
return; return;
@@ -223,25 +237,23 @@ static void smscb_fsm_deleted_onenter(struct osmo_fsm_inst *fi, uint32_t old_sta
static struct osmo_fsm_state smscb_fsm_states[] = { static struct osmo_fsm_state smscb_fsm_states[] = {
[SMSCB_S_INIT] = { [SMSCB_S_INIT] = {
.name = "INIT", .name = "INIT",
.in_event_mask = S(SMSCB_E_CREATE), .in_event_mask = S(SMSCB_MSG_E_CREATE),
.out_state_mask = S(SMSCB_S_WAIT_WRITE_ACK), .out_state_mask = S(SMSCB_S_WAIT_WRITE_ACK),
.action = smscb_fsm_init, .action = smscb_fsm_init,
}, },
[SMSCB_S_WAIT_WRITE_ACK] = { [SMSCB_S_WAIT_WRITE_ACK] = {
.name = "WAIT_WRITE_ACK", .name = "WAIT_WRITE_ACK",
.in_event_mask = S(SMSCB_E_CBSP_WRITE_ACK) | .in_event_mask = S(SMSCB_MSG_E_WRITE_ACK) |
S(SMSCB_E_CBSP_WRITE_NACK) | S(SMSCB_MSG_E_WRITE_NACK),
S(SMSCB_E_SBCAP_WRITE_ACK) |
S(SMSCB_E_SBCAP_WRITE_NACK),
.out_state_mask = S(SMSCB_S_ACTIVE), .out_state_mask = S(SMSCB_S_ACTIVE),
.action = smscb_fsm_wait_write_ack, .action = smscb_fsm_wait_write_ack,
.onleave = smscb_fsm_wait_write_ack_onleave, .onleave = smscb_fsm_wait_write_ack_onleave,
}, },
[SMSCB_S_ACTIVE] = { [SMSCB_S_ACTIVE] = {
.name = "ACTIVE", .name = "ACTIVE",
.in_event_mask = S(SMSCB_E_REPLACE) | .in_event_mask = S(SMSCB_MSG_E_REPLACE) |
S(SMSCB_E_STATUS) | S(SMSCB_MSG_E_STATUS) |
S(SMSCB_E_DELETE), S(SMSCB_MSG_E_DELETE),
.out_state_mask = S(SMSCB_S_ACTIVE) | .out_state_mask = S(SMSCB_S_ACTIVE) |
S(SMSCB_S_WAIT_REPLACE_ACK) | S(SMSCB_S_WAIT_REPLACE_ACK) |
S(SMSCB_S_WAIT_STATUS_ACK) | S(SMSCB_S_WAIT_STATUS_ACK) |
@@ -250,26 +262,24 @@ static struct osmo_fsm_state smscb_fsm_states[] = {
}, },
[SMSCB_S_WAIT_REPLACE_ACK] = { [SMSCB_S_WAIT_REPLACE_ACK] = {
.name = "WAIT_REPLACE_ACK", .name = "WAIT_REPLACE_ACK",
.in_event_mask = S(SMSCB_E_CBSP_REPLACE_ACK) | .in_event_mask = S(SMSCB_MSG_E_REPLACE_ACK) |
S(SMSCB_E_CBSP_REPLACE_NACK), S(SMSCB_MSG_E_REPLACE_NACK),
.out_state_mask = S(SMSCB_S_ACTIVE), .out_state_mask = S(SMSCB_S_ACTIVE),
.action = smscb_fsm_wait_replace_ack, .action = smscb_fsm_wait_replace_ack,
.onleave = smscb_fsm_wait_replace_ack_onleave, .onleave = smscb_fsm_wait_replace_ack_onleave,
}, },
[SMSCB_S_WAIT_STATUS_ACK] = { [SMSCB_S_WAIT_STATUS_ACK] = {
.name = "WAIT_STATUS_ACK", .name = "WAIT_STATUS_ACK",
.in_event_mask = S(SMSCB_E_CBSP_STATUS_ACK) | .in_event_mask = S(SMSCB_MSG_E_STATUS_ACK) |
S(SMSCB_E_CBSP_STATUS_NACK), S(SMSCB_MSG_E_STATUS_NACK),
.out_state_mask = S(SMSCB_S_ACTIVE), .out_state_mask = S(SMSCB_S_ACTIVE),
.action = smscb_fsm_wait_status_ack, .action = smscb_fsm_wait_status_ack,
.onleave = smscb_fsm_wait_status_ack_onleave, .onleave = smscb_fsm_wait_status_ack_onleave,
}, },
[SMSCB_S_WAIT_DELETE_ACK] = { [SMSCB_S_WAIT_DELETE_ACK] = {
.name = "WAIT_DELETE_ACK", .name = "WAIT_DELETE_ACK",
.in_event_mask = S(SMSCB_E_CBSP_DELETE_ACK) | .in_event_mask = S(SMSCB_MSG_E_DELETE_ACK) |
S(SMSCB_E_CBSP_DELETE_NACK) | S(SMSCB_MSG_E_DELETE_NACK),
S(SMSCB_E_SBCAP_DELETE_ACK) |
S(SMSCB_E_SBCAP_DELETE_NACK),
.out_state_mask = S(SMSCB_S_DELETED), .out_state_mask = S(SMSCB_S_DELETED),
.action = smscb_fsm_wait_delete_ack, .action = smscb_fsm_wait_delete_ack,
.onleave = smscb_fsm_wait_delete_ack_onleave, .onleave = smscb_fsm_wait_delete_ack_onleave,
@@ -311,7 +321,7 @@ static int smscb_fsm_timer_cb(struct osmo_fsm_inst *fi)
static void smscb_fsm_allstate(struct osmo_fsm_inst *Fi, uint32_t event, void *data) static void smscb_fsm_allstate(struct osmo_fsm_inst *Fi, uint32_t event, void *data)
{ {
switch (event) { switch (event) {
case SMSCB_E_CHILD_DIED: case SMSCB_MSG_E_CHILD_DIED:
break; break;
default: default:
OSMO_ASSERT(0); OSMO_ASSERT(0);
@@ -332,11 +342,11 @@ static struct osmo_fsm smscb_fsm = {
.name = "SMSCB", .name = "SMSCB",
.states = smscb_fsm_states, .states = smscb_fsm_states,
.num_states = ARRAY_SIZE(smscb_fsm_states), .num_states = ARRAY_SIZE(smscb_fsm_states),
.allstate_event_mask = S(SMSCB_E_CHILD_DIED), .allstate_event_mask = S(SMSCB_MSG_E_CHILD_DIED),
.allstate_action = smscb_fsm_allstate, .allstate_action = smscb_fsm_allstate,
.timer_cb = smscb_fsm_timer_cb, .timer_cb = smscb_fsm_timer_cb,
.log_subsys = DSMSCB, .log_subsys = DSMSCB,
.event_names = smscb_fsm_event_names, .event_names = smscb_message_fsm_event_names,
.cleanup= smscb_fsm_cleanup, .cleanup= smscb_fsm_cleanup,
}; };

View File

@@ -40,29 +40,29 @@
#include <osmocom/cbc/sbcap_link.h> #include <osmocom/cbc/sbcap_link.h>
#include <osmocom/cbc/sbcap_msg.h> #include <osmocom/cbc/sbcap_msg.h>
#include <osmocom/cbc/debug.h> #include <osmocom/cbc/debug.h>
#include <osmocom/cbc/smscb_peer_fsm.h>
#include <osmocom/cbc/smscb_message_fsm.h> #include <osmocom/cbc/smscb_message_fsm.h>
#define S(x) (1 << (x)) #define S(x) (1 << (x))
const struct value_string smscb_fsm_event_names[] = { const struct value_string smscb_peer_fsm_event_names[] = {
{ SMSCB_E_CHILD_DIED, "CHILD_DIED" }, { SMSCB_PEER_E_CREATE, "CREATE" },
{ SMSCB_E_CREATE, "CREATE" }, { SMSCB_PEER_E_REPLACE, "REPLACE" },
{ SMSCB_E_REPLACE, "REPLACE" }, { SMSCB_PEER_E_STATUS, "STATUS" },
{ SMSCB_E_STATUS, "STATUS" }, { SMSCB_PEER_E_DELETE, "DELETE" },
{ SMSCB_E_DELETE, "DELETE" }, { SMSCB_PEER_E_CBSP_WRITE_ACK, "CBSP_WRITE_ACK" },
{ SMSCB_E_CBSP_WRITE_ACK, "CBSP_WRITE_ACK" }, { SMSCB_PEER_E_CBSP_WRITE_NACK, "CBSP_WRITE_NACK" },
{ SMSCB_E_CBSP_WRITE_NACK, "CBSP_WRITE_NACK" }, { SMSCB_PEER_E_CBSP_REPLACE_ACK, "CBSP_REPLACE_ACK" },
{ SMSCB_E_CBSP_REPLACE_ACK, "CBSP_REPLACE_ACK" }, { SMSCB_PEER_E_CBSP_REPLACE_NACK, "CBSP_REPLACE_NACK" },
{ SMSCB_E_CBSP_REPLACE_NACK, "CBSP_REPLACE_NACK" }, { SMSCB_PEER_E_CBSP_DELETE_ACK, "CBSP_DELETE_ACK" },
{ SMSCB_E_CBSP_DELETE_ACK, "CBSP_DELETE_ACK" }, { SMSCB_PEER_E_CBSP_DELETE_NACK, "CBSP_DELETE_NACK" },
{ SMSCB_E_CBSP_DELETE_NACK, "CBSP_DELETE_NACK" }, { SMSCB_PEER_E_CBSP_STATUS_ACK, "CBSP_STATUS_ACK" },
{ SMSCB_E_CBSP_STATUS_ACK, "CBSP_STATUS_ACK" }, { SMSCB_PEER_E_CBSP_STATUS_NACK, "CBSP_STATUS_NACK" },
{ SMSCB_E_CBSP_STATUS_NACK, "CBSP_STATUS_NACK" }, { SMSCB_PEER_E_SBCAP_WRITE_ACK, "SBcAP_WRITE_ACK" },
{ SMSCB_E_SBCAP_WRITE_ACK, "SBcAP_WRITE_ACK" }, { SMSCB_PEER_E_SBCAP_WRITE_NACK, "SBcAP_WRITE_NACK" },
{ SMSCB_E_SBCAP_WRITE_NACK, "SBcAP_WRITE_NACK" }, { SMSCB_PEER_E_SBCAP_DELETE_ACK, "SBcAP_DELETE_ACK" },
{ SMSCB_E_SBCAP_DELETE_ACK, "SBcAP_DELETE_ACK" }, { SMSCB_PEER_E_SBCAP_DELETE_NACK, "SBcAP_DELETE_NACK" },
{ SMSCB_E_SBCAP_DELETE_NACK, "SBcAP_DELETE_NACK" }, { SMSCB_PEER_E_SBCAP_WRITE_IND, "SBcAP_WRITE_IND" },
{ SMSCB_E_SBCAP_WRITE_IND, "SBcAP_WRITE_IND" },
{ 0, NULL } { 0, NULL }
}; };
@@ -349,7 +349,7 @@ static void smscb_p_fsm_init(struct osmo_fsm_inst *fi, uint32_t event, void *dat
int rc; int rc;
switch (event) { switch (event) {
case SMSCB_E_CREATE: case SMSCB_PEER_E_CREATE:
/* send it to peer */ /* send it to peer */
rc = peer_new_cbc_message(mp->peer, mp->cbcmsg); rc = peer_new_cbc_message(mp->peer, mp->cbcmsg);
if (rc == 0) { if (rc == 0) {
@@ -372,24 +372,24 @@ static void smscb_p_fsm_wait_write_ack(struct osmo_fsm_inst *fi, uint32_t event,
SBcAP_Write_Replace_Warning_Response_IEs_t *ie; SBcAP_Write_Replace_Warning_Response_IEs_t *ie;
switch (event) { switch (event) {
case SMSCB_E_CBSP_WRITE_ACK: case SMSCB_PEER_E_CBSP_WRITE_ACK:
dec = data; dec = data;
msg_peer_append_cbsp_compl(mp, &dec->u.write_replace_compl.num_compl_list); msg_peer_append_cbsp_compl(mp, &dec->u.write_replace_compl.num_compl_list);
msg_peer_append_cbsp_cell(mp, &dec->u.write_replace_compl.cell_list); msg_peer_append_cbsp_cell(mp, &dec->u.write_replace_compl.cell_list);
osmo_fsm_inst_state_chg(fi, SMSCB_S_ACTIVE, 0, 0); osmo_fsm_inst_state_chg(fi, SMSCB_S_ACTIVE, 0, 0);
/* Signal parent fsm about completion */ /* Signal parent fsm about completion */
osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_E_CBSP_WRITE_ACK, mp); osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_MSG_E_WRITE_ACK, mp);
break; break;
case SMSCB_E_CBSP_WRITE_NACK: case SMSCB_PEER_E_CBSP_WRITE_NACK:
dec = data; dec = data;
msg_peer_append_cbsp_compl(mp, &dec->u.write_replace_fail.num_compl_list); msg_peer_append_cbsp_compl(mp, &dec->u.write_replace_fail.num_compl_list);
msg_peer_append_cbsp_cell(mp, &dec->u.write_replace_fail.cell_list); msg_peer_append_cbsp_cell(mp, &dec->u.write_replace_fail.cell_list);
msg_peer_append_cbsp_fail(mp, &dec->u.write_replace_fail.fail_list); msg_peer_append_cbsp_fail(mp, &dec->u.write_replace_fail.fail_list);
osmo_fsm_inst_state_chg(fi, SMSCB_S_ACTIVE, 0, 0); osmo_fsm_inst_state_chg(fi, SMSCB_S_ACTIVE, 0, 0);
/* Signal parent fsm about completion */ /* Signal parent fsm about completion */
osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_E_CBSP_WRITE_NACK, mp); osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_MSG_E_WRITE_NACK, mp);
break; break;
case SMSCB_E_SBCAP_WRITE_ACK: case SMSCB_PEER_E_SBCAP_WRITE_ACK:
sbcap = data; sbcap = data;
OSMO_ASSERT(sbcap->present == SBcAP_SBC_AP_PDU_PR_successfulOutcome); OSMO_ASSERT(sbcap->present == SBcAP_SBC_AP_PDU_PR_successfulOutcome);
OSMO_ASSERT(sbcap->choice.successfulOutcome.procedureCode == SBcAP_ProcedureId_Write_Replace_Warning); OSMO_ASSERT(sbcap->choice.successfulOutcome.procedureCode == SBcAP_ProcedureId_Write_Replace_Warning);
@@ -402,12 +402,12 @@ static void smscb_p_fsm_wait_write_ack(struct osmo_fsm_inst *fi, uint32_t event,
} }
osmo_fsm_inst_state_chg(fi, SMSCB_S_ACTIVE, 0, 0); osmo_fsm_inst_state_chg(fi, SMSCB_S_ACTIVE, 0, 0);
/* Signal parent fsm about completion */ /* Signal parent fsm about completion */
osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_E_SBCAP_WRITE_ACK, mp); osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_MSG_E_WRITE_ACK, mp);
break; break;
case SMSCB_E_SBCAP_WRITE_NACK: case SMSCB_PEER_E_SBCAP_WRITE_NACK:
osmo_fsm_inst_state_chg(fi, SMSCB_S_ACTIVE, 0, 0); osmo_fsm_inst_state_chg(fi, SMSCB_S_ACTIVE, 0, 0);
/* Signal parent fsm about completion */ /* Signal parent fsm about completion */
osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_E_SBCAP_WRITE_NACK, mp); osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_MSG_E_WRITE_NACK, mp);
break; break;
default: default:
OSMO_ASSERT(0); OSMO_ASSERT(0);
@@ -420,7 +420,7 @@ static void smscb_p_fsm_active(struct osmo_fsm_inst *fi, uint32_t event, void *d
struct osmo_cbsp_decoded *cbsp; struct osmo_cbsp_decoded *cbsp;
switch (event) { switch (event) {
case SMSCB_E_REPLACE: /* send WRITE-REPLACE to BSC */ case SMSCB_PEER_E_REPLACE: /* send WRITE-REPLACE to BSC */
cbsp = osmo_cbsp_decoded_alloc(mp->peer, CBSP_MSGT_WRITE_REPLACE); cbsp = osmo_cbsp_decoded_alloc(mp->peer, CBSP_MSGT_WRITE_REPLACE);
OSMO_ASSERT(cbsp); OSMO_ASSERT(cbsp);
cbsp->u.write_replace.msg_id = mp->cbcmsg->msg.message_id; cbsp->u.write_replace.msg_id = mp->cbcmsg->msg.message_id;
@@ -432,7 +432,7 @@ static void smscb_p_fsm_active(struct osmo_fsm_inst *fi, uint32_t event, void *d
cbc_cbsp_link_tx(mp->peer->link.cbsp, cbsp); cbc_cbsp_link_tx(mp->peer->link.cbsp, cbsp);
osmo_fsm_inst_state_chg(fi, SMSCB_S_WAIT_REPLACE_ACK, 10, T_WAIT_REPLACE_ACK); osmo_fsm_inst_state_chg(fi, SMSCB_S_WAIT_REPLACE_ACK, 10, T_WAIT_REPLACE_ACK);
break; break;
case SMSCB_E_STATUS: /* send MSG-STATUS-QUERY to BSC */ case SMSCB_PEER_E_STATUS: /* send MSG-STATUS-QUERY to BSC */
cbsp = osmo_cbsp_decoded_alloc(mp->peer, CBSP_MSGT_MSG_STATUS_QUERY); cbsp = osmo_cbsp_decoded_alloc(mp->peer, CBSP_MSGT_MSG_STATUS_QUERY);
OSMO_ASSERT(cbsp); OSMO_ASSERT(cbsp);
cbsp->u.msg_status_query.msg_id = mp->cbcmsg->msg.message_id; cbsp->u.msg_status_query.msg_id = mp->cbcmsg->msg.message_id;
@@ -453,20 +453,20 @@ static void smscb_p_fsm_wait_status_ack(struct osmo_fsm_inst *fi, uint32_t event
struct osmo_cbsp_decoded *dec = NULL; struct osmo_cbsp_decoded *dec = NULL;
switch (event) { switch (event) {
case SMSCB_E_CBSP_STATUS_ACK: case SMSCB_PEER_E_CBSP_STATUS_ACK:
dec = data; dec = data;
msg_peer_append_cbsp_compl(mp, &dec->u.msg_status_query_compl.num_compl_list); msg_peer_append_cbsp_compl(mp, &dec->u.msg_status_query_compl.num_compl_list);
osmo_fsm_inst_state_chg(fi, SMSCB_S_ACTIVE, 0, 0); osmo_fsm_inst_state_chg(fi, SMSCB_S_ACTIVE, 0, 0);
/* Signal parent fsm about completion */ /* Signal parent fsm about completion */
osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_E_CBSP_STATUS_ACK, mp); osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_MSG_E_STATUS_ACK, mp);
break; break;
case SMSCB_E_CBSP_STATUS_NACK: case SMSCB_PEER_E_CBSP_STATUS_NACK:
dec = data; dec = data;
msg_peer_append_cbsp_compl(mp, &dec->u.msg_status_query_fail.num_compl_list); msg_peer_append_cbsp_compl(mp, &dec->u.msg_status_query_fail.num_compl_list);
msg_peer_append_cbsp_fail(mp, &dec->u.msg_status_query_fail.fail_list); msg_peer_append_cbsp_fail(mp, &dec->u.msg_status_query_fail.fail_list);
osmo_fsm_inst_state_chg(fi, SMSCB_S_ACTIVE, 0, 0); osmo_fsm_inst_state_chg(fi, SMSCB_S_ACTIVE, 0, 0);
/* Signal parent fsm about completion */ /* Signal parent fsm about completion */
osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_E_CBSP_STATUS_NACK, mp); osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_MSG_E_STATUS_NACK, mp);
break; break;
default: default:
OSMO_ASSERT(0); OSMO_ASSERT(0);
@@ -480,22 +480,22 @@ static void smscb_p_fsm_wait_replace_ack(struct osmo_fsm_inst *fi, uint32_t even
struct osmo_cbsp_decoded *dec = NULL; struct osmo_cbsp_decoded *dec = NULL;
switch (event) { switch (event) {
case SMSCB_E_CBSP_REPLACE_ACK: case SMSCB_PEER_E_CBSP_REPLACE_ACK:
dec = data; dec = data;
msg_peer_append_cbsp_compl(mp, &dec->u.write_replace_compl.num_compl_list); msg_peer_append_cbsp_compl(mp, &dec->u.write_replace_compl.num_compl_list);
msg_peer_append_cbsp_cell(mp, &dec->u.write_replace_compl.cell_list); msg_peer_append_cbsp_cell(mp, &dec->u.write_replace_compl.cell_list);
osmo_fsm_inst_state_chg(fi, SMSCB_S_ACTIVE, 0, 0); osmo_fsm_inst_state_chg(fi, SMSCB_S_ACTIVE, 0, 0);
/* Signal parent fsm about completion */ /* Signal parent fsm about completion */
osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_E_CBSP_REPLACE_ACK, mp); osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_MSG_E_REPLACE_ACK, mp);
break; break;
case SMSCB_E_CBSP_REPLACE_NACK: case SMSCB_PEER_E_CBSP_REPLACE_NACK:
dec = data; dec = data;
msg_peer_append_cbsp_compl(mp, &dec->u.write_replace_fail.num_compl_list); msg_peer_append_cbsp_compl(mp, &dec->u.write_replace_fail.num_compl_list);
msg_peer_append_cbsp_cell(mp, &dec->u.write_replace_fail.cell_list); msg_peer_append_cbsp_cell(mp, &dec->u.write_replace_fail.cell_list);
msg_peer_append_cbsp_fail(mp, &dec->u.write_replace_fail.fail_list); msg_peer_append_cbsp_fail(mp, &dec->u.write_replace_fail.fail_list);
osmo_fsm_inst_state_chg(fi, SMSCB_S_ACTIVE, 0, 0); osmo_fsm_inst_state_chg(fi, SMSCB_S_ACTIVE, 0, 0);
/* Signal parent fsm about completion */ /* Signal parent fsm about completion */
osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_E_CBSP_REPLACE_NACK, mp); osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_MSG_E_REPLACE_NACK, mp);
break; break;
default: default:
OSMO_ASSERT(0); OSMO_ASSERT(0);
@@ -509,16 +509,16 @@ static void smscb_p_fsm_wait_delete_ack(struct osmo_fsm_inst *fi, uint32_t event
//SBcAP_SBC_AP_PDU_t *pdu = NULL; //SBcAP_SBC_AP_PDU_t *pdu = NULL;
switch (event) { switch (event) {
case SMSCB_E_CBSP_DELETE_ACK: case SMSCB_PEER_E_CBSP_DELETE_ACK:
dec = data; dec = data;
/* append results */ /* append results */
msg_peer_append_cbsp_compl(mp, &dec->u.kill_compl.num_compl_list); msg_peer_append_cbsp_compl(mp, &dec->u.kill_compl.num_compl_list);
msg_peer_append_cbsp_cell(mp, &dec->u.kill_compl.cell_list); msg_peer_append_cbsp_cell(mp, &dec->u.kill_compl.cell_list);
osmo_fsm_inst_state_chg(fi, SMSCB_S_DELETED, 0, 0); osmo_fsm_inst_state_chg(fi, SMSCB_S_DELETED, 0, 0);
/* Signal parent fsm about completion */ /* Signal parent fsm about completion */
osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_E_CBSP_DELETE_ACK, mp); osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_MSG_E_DELETE_ACK, mp);
break; break;
case SMSCB_E_CBSP_DELETE_NACK: case SMSCB_PEER_E_CBSP_DELETE_NACK:
dec = data; dec = data;
/* append results */ /* append results */
msg_peer_append_cbsp_compl(mp, &dec->u.kill_fail.num_compl_list); msg_peer_append_cbsp_compl(mp, &dec->u.kill_fail.num_compl_list);
@@ -526,19 +526,19 @@ static void smscb_p_fsm_wait_delete_ack(struct osmo_fsm_inst *fi, uint32_t event
msg_peer_append_cbsp_fail(mp, &dec->u.kill_fail.fail_list); msg_peer_append_cbsp_fail(mp, &dec->u.kill_fail.fail_list);
osmo_fsm_inst_state_chg(fi, SMSCB_S_DELETED, 0, 0); osmo_fsm_inst_state_chg(fi, SMSCB_S_DELETED, 0, 0);
/* Signal parent fsm about completion */ /* Signal parent fsm about completion */
osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_E_CBSP_DELETE_NACK, mp); osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_MSG_E_DELETE_NACK, mp);
break; break;
case SMSCB_E_SBCAP_DELETE_ACK: case SMSCB_PEER_E_SBCAP_DELETE_ACK:
//pdu = data; //pdu = data;
osmo_fsm_inst_state_chg(fi, SMSCB_S_DELETED, 0, 0); osmo_fsm_inst_state_chg(fi, SMSCB_S_DELETED, 0, 0);
/* Signal parent fsm about completion */ /* Signal parent fsm about completion */
osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_E_SBCAP_DELETE_ACK, mp); osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_MSG_E_DELETE_ACK, mp);
break; break;
case SMSCB_E_SBCAP_DELETE_NACK: case SMSCB_PEER_E_SBCAP_DELETE_NACK:
//pdu = data; //pdu = data;
osmo_fsm_inst_state_chg(fi, SMSCB_S_DELETED, 0, 0); osmo_fsm_inst_state_chg(fi, SMSCB_S_DELETED, 0, 0);
/* Signal parent fsm about completion */ /* Signal parent fsm about completion */
osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_E_SBCAP_DELETE_NACK, mp); osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_MSG_E_DELETE_NACK, mp);
break; break;
default: default:
OSMO_ASSERT(0); OSMO_ASSERT(0);
@@ -549,44 +549,22 @@ static void smscb_p_fsm_wait_delete_ack(struct osmo_fsm_inst *fi, uint32_t event
static int smscb_p_fsm_timer_cb(struct osmo_fsm_inst *fi) static int smscb_p_fsm_timer_cb(struct osmo_fsm_inst *fi)
{ {
struct cbc_message_peer *mp = (struct cbc_message_peer *)fi->priv;
int ev;
switch (fi->T) { switch (fi->T) {
case T_WAIT_WRITE_ACK: case T_WAIT_WRITE_ACK:
osmo_fsm_inst_state_chg(fi, SMSCB_S_ACTIVE, 0, 0); osmo_fsm_inst_state_chg(fi, SMSCB_S_ACTIVE, 0, 0);
switch (mp->peer->proto) { osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_MSG_E_WRITE_NACK, NULL);
case CBC_PEER_PROTO_CBSP:
ev = SMSCB_E_CBSP_WRITE_NACK;
break;
case CBC_PEER_PROTO_SBcAP:
ev = SMSCB_E_SBCAP_WRITE_NACK;
break;
default:
OSMO_ASSERT(0);
}
osmo_fsm_inst_dispatch(fi->proc.parent, ev, NULL);
break; break;
case T_WAIT_REPLACE_ACK: case T_WAIT_REPLACE_ACK:
osmo_fsm_inst_state_chg(fi, SMSCB_S_ACTIVE, 0, 0); osmo_fsm_inst_state_chg(fi, SMSCB_S_ACTIVE, 0, 0);
osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_E_CBSP_REPLACE_NACK, NULL); osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_MSG_E_REPLACE_NACK, NULL);
break; break;
case T_WAIT_STATUS_ACK: case T_WAIT_STATUS_ACK:
osmo_fsm_inst_state_chg(fi, SMSCB_S_ACTIVE, 0, 0); osmo_fsm_inst_state_chg(fi, SMSCB_S_ACTIVE, 0, 0);
osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_E_CBSP_STATUS_NACK, NULL); osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_MSG_E_STATUS_NACK, NULL);
break; break;
case T_WAIT_DELETE_ACK: case T_WAIT_DELETE_ACK:
osmo_fsm_inst_state_chg(fi, SMSCB_S_DELETED, 0, 0); osmo_fsm_inst_state_chg(fi, SMSCB_S_DELETED, 0, 0);
switch (mp->peer->proto) { osmo_fsm_inst_dispatch(fi->proc.parent, SMSCB_MSG_E_DELETE_NACK, NULL);
case CBC_PEER_PROTO_CBSP:
ev = SMSCB_E_CBSP_DELETE_NACK;
break;
case CBC_PEER_PROTO_SBcAP:
ev = SMSCB_E_SBCAP_DELETE_NACK;
break;
default:
OSMO_ASSERT(0);
}
osmo_fsm_inst_dispatch(fi->proc.parent, ev, NULL);
break; break;
default: default:
OSMO_ASSERT(0); OSMO_ASSERT(0);
@@ -603,7 +581,7 @@ static void smscb_p_fsm_allstate(struct osmo_fsm_inst *fi, uint32_t event, void
SBcAP_Write_Replace_Warning_Indication_IEs_t *ie; SBcAP_Write_Replace_Warning_Indication_IEs_t *ie;
switch (event) { switch (event) {
case SMSCB_E_DELETE: /* send KILL to BSC */ case SMSCB_PEER_E_DELETE: /* send KILL to BSC */
switch (fi->state) { switch (fi->state) {
case SMSCB_S_DELETED: case SMSCB_S_DELETED:
case SMSCB_S_INIT: case SMSCB_S_INIT:
@@ -640,11 +618,11 @@ static void smscb_p_fsm_allstate(struct osmo_fsm_inst *fi, uint32_t event, void
break; break;
case CBC_PEER_PROTO_SABP: case CBC_PEER_PROTO_SABP:
default: default:
osmo_panic("SMSCB_E_DELETE not implemented for proto %u", mp->peer->proto); osmo_panic("SMSCB_PEER_E_DELETE not implemented for proto %u", mp->peer->proto);
} }
osmo_fsm_inst_state_chg(fi, SMSCB_S_WAIT_DELETE_ACK, 10, T_WAIT_DELETE_ACK); osmo_fsm_inst_state_chg(fi, SMSCB_S_WAIT_DELETE_ACK, 10, T_WAIT_DELETE_ACK);
break; break;
case SMSCB_E_SBCAP_WRITE_IND: case SMSCB_PEER_E_SBCAP_WRITE_IND:
sbcap = (SBcAP_SBC_AP_PDU_t *)data; sbcap = (SBcAP_SBC_AP_PDU_t *)data;
OSMO_ASSERT(sbcap->present == SBcAP_SBC_AP_PDU_PR_initiatingMessage); OSMO_ASSERT(sbcap->present == SBcAP_SBC_AP_PDU_PR_initiatingMessage);
OSMO_ASSERT(sbcap->choice.initiatingMessage.procedureCode == SBcAP_ProcedureId_Write_Replace_Warning_Indication); OSMO_ASSERT(sbcap->choice.initiatingMessage.procedureCode == SBcAP_ProcedureId_Write_Replace_Warning_Indication);
@@ -671,24 +649,24 @@ static void smscb_p_fsm_cleanup(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cau
static const struct osmo_fsm_state smscb_p_fsm_states[] = { static const struct osmo_fsm_state smscb_p_fsm_states[] = {
[SMSCB_S_INIT] = { [SMSCB_S_INIT] = {
.name = "INIT", .name = "INIT",
.in_event_mask = S(SMSCB_E_CREATE), .in_event_mask = S(SMSCB_PEER_E_CREATE),
.out_state_mask = S(SMSCB_S_WAIT_WRITE_ACK), .out_state_mask = S(SMSCB_S_WAIT_WRITE_ACK),
.action = smscb_p_fsm_init, .action = smscb_p_fsm_init,
}, },
[SMSCB_S_WAIT_WRITE_ACK] = { [SMSCB_S_WAIT_WRITE_ACK] = {
.name = "WAIT_WRITE_ACK", .name = "WAIT_WRITE_ACK",
.in_event_mask = S(SMSCB_E_CBSP_WRITE_ACK) | .in_event_mask = S(SMSCB_PEER_E_CBSP_WRITE_ACK) |
S(SMSCB_E_CBSP_WRITE_NACK) | S(SMSCB_PEER_E_CBSP_WRITE_NACK) |
S(SMSCB_E_SBCAP_WRITE_ACK) | S(SMSCB_PEER_E_SBCAP_WRITE_ACK) |
S(SMSCB_E_SBCAP_WRITE_NACK), S(SMSCB_PEER_E_SBCAP_WRITE_NACK),
.out_state_mask = S(SMSCB_S_ACTIVE) | .out_state_mask = S(SMSCB_S_ACTIVE) |
S(SMSCB_S_WAIT_DELETE_ACK), S(SMSCB_S_WAIT_DELETE_ACK),
.action = smscb_p_fsm_wait_write_ack, .action = smscb_p_fsm_wait_write_ack,
}, },
[SMSCB_S_ACTIVE] = { [SMSCB_S_ACTIVE] = {
.name = "ACTIVE", .name = "ACTIVE",
.in_event_mask = S(SMSCB_E_REPLACE) | .in_event_mask = S(SMSCB_PEER_E_REPLACE) |
S(SMSCB_E_STATUS), S(SMSCB_PEER_E_STATUS),
.out_state_mask = S(SMSCB_S_WAIT_REPLACE_ACK) | .out_state_mask = S(SMSCB_S_WAIT_REPLACE_ACK) |
S(SMSCB_S_WAIT_STATUS_ACK) | S(SMSCB_S_WAIT_STATUS_ACK) |
S(SMSCB_S_WAIT_DELETE_ACK), S(SMSCB_S_WAIT_DELETE_ACK),
@@ -696,26 +674,26 @@ static const struct osmo_fsm_state smscb_p_fsm_states[] = {
}, },
[SMSCB_S_WAIT_STATUS_ACK] = { [SMSCB_S_WAIT_STATUS_ACK] = {
.name = "WAIT_STATUS_ACK", .name = "WAIT_STATUS_ACK",
.in_event_mask = S(SMSCB_E_CBSP_STATUS_ACK) | .in_event_mask = S(SMSCB_PEER_E_CBSP_STATUS_ACK) |
S(SMSCB_E_CBSP_STATUS_NACK), S(SMSCB_PEER_E_CBSP_STATUS_NACK),
.out_state_mask = S(SMSCB_S_ACTIVE) | .out_state_mask = S(SMSCB_S_ACTIVE) |
S(SMSCB_S_WAIT_DELETE_ACK), S(SMSCB_S_WAIT_DELETE_ACK),
.action = smscb_p_fsm_wait_status_ack, .action = smscb_p_fsm_wait_status_ack,
}, },
[SMSCB_S_WAIT_REPLACE_ACK] = { [SMSCB_S_WAIT_REPLACE_ACK] = {
.name = "WAIT_REPLACE_ACK", .name = "WAIT_REPLACE_ACK",
.in_event_mask = S(SMSCB_E_CBSP_REPLACE_ACK) | .in_event_mask = S(SMSCB_PEER_E_CBSP_REPLACE_ACK) |
S(SMSCB_E_CBSP_REPLACE_NACK), S(SMSCB_PEER_E_CBSP_REPLACE_NACK),
.out_state_mask = S(SMSCB_S_ACTIVE) | .out_state_mask = S(SMSCB_S_ACTIVE) |
S(SMSCB_S_WAIT_DELETE_ACK), S(SMSCB_S_WAIT_DELETE_ACK),
.action = smscb_p_fsm_wait_replace_ack, .action = smscb_p_fsm_wait_replace_ack,
}, },
[SMSCB_S_WAIT_DELETE_ACK] = { [SMSCB_S_WAIT_DELETE_ACK] = {
.name = "WAIT_DELETE_ACK", .name = "WAIT_DELETE_ACK",
.in_event_mask = S(SMSCB_E_CBSP_DELETE_ACK) | .in_event_mask = S(SMSCB_PEER_E_CBSP_DELETE_ACK) |
S(SMSCB_E_CBSP_DELETE_NACK) | S(SMSCB_PEER_E_CBSP_DELETE_NACK) |
S(SMSCB_E_SBCAP_DELETE_ACK) | S(SMSCB_PEER_E_SBCAP_DELETE_ACK) |
S(SMSCB_E_SBCAP_DELETE_NACK), S(SMSCB_PEER_E_SBCAP_DELETE_NACK),
.out_state_mask = S(SMSCB_S_DELETED), .out_state_mask = S(SMSCB_S_DELETED),
.action = smscb_p_fsm_wait_delete_ack, .action = smscb_p_fsm_wait_delete_ack,
}, },
@@ -728,12 +706,12 @@ struct osmo_fsm smscb_p_fsm = {
.name = "SMSCB-PEER", .name = "SMSCB-PEER",
.states = smscb_p_fsm_states, .states = smscb_p_fsm_states,
.num_states = ARRAY_SIZE(smscb_p_fsm_states), .num_states = ARRAY_SIZE(smscb_p_fsm_states),
.allstate_event_mask = S(SMSCB_E_DELETE) | .allstate_event_mask = S(SMSCB_PEER_E_DELETE) |
S(SMSCB_E_SBCAP_WRITE_IND), S(SMSCB_PEER_E_SBCAP_WRITE_IND),
.allstate_action = smscb_p_fsm_allstate, .allstate_action = smscb_p_fsm_allstate,
.timer_cb = smscb_p_fsm_timer_cb, .timer_cb = smscb_p_fsm_timer_cb,
.log_subsys = DCBSP, .log_subsys = DCBSP,
.event_names = smscb_fsm_event_names, .event_names = smscb_peer_fsm_event_names,
.cleanup = smscb_p_fsm_cleanup, .cleanup = smscb_p_fsm_cleanup,
}; };
@@ -747,7 +725,7 @@ struct cbc_message_peer *smscb_peer_fsm_alloc(struct cbc_peer *peer, struct cbc_
struct cbc_message_peer *mp; struct cbc_message_peer *mp;
struct osmo_fsm_inst *fi; struct osmo_fsm_inst *fi;
fi = osmo_fsm_inst_alloc_child(&smscb_p_fsm, cbcmsg->fi, SMSCB_E_CHILD_DIED); fi = osmo_fsm_inst_alloc_child(&smscb_p_fsm, cbcmsg->fi, SMSCB_MSG_E_CHILD_DIED);
if (!fi) if (!fi)
return NULL; return NULL;
/* include the peer name in the ID of the child FSM */ /* include the peer name in the ID of the child FSM */