mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-cbc.git
synced 2025-11-03 13:43:37 +00:00
Propagate error to caller when tx cbsp/sbcap Write-Replace-Req fails
Change-Id: Ie40c8e41c297398bbec48f7bb2c60cfdc703fa5d
This commit is contained in:
@@ -47,6 +47,6 @@ struct cbc_cbsp_link *cbc_cbsp_link_alloc(struct cbc_cbsp_mgr *cbc, struct cbc_p
|
|||||||
void cbc_cbsp_link_free(struct cbc_cbsp_link *link);
|
void cbc_cbsp_link_free(struct cbc_cbsp_link *link);
|
||||||
const char *cbc_cbsp_link_name(const struct cbc_cbsp_link *link);
|
const char *cbc_cbsp_link_name(const struct cbc_cbsp_link *link);
|
||||||
int cbc_cbsp_link_open_cli(struct cbc_cbsp_link *link);
|
int cbc_cbsp_link_open_cli(struct cbc_cbsp_link *link);
|
||||||
void cbc_cbsp_link_tx(struct cbc_cbsp_link *link, struct osmo_cbsp_decoded *cbsp);
|
int cbc_cbsp_link_tx(struct cbc_cbsp_link *link, struct osmo_cbsp_decoded *cbsp);
|
||||||
void cbc_cbsp_link_close(struct cbc_cbsp_link *link);
|
void cbc_cbsp_link_close(struct cbc_cbsp_link *link);
|
||||||
int cbc_cbsp_link_rx_cb(struct cbc_cbsp_link *link, struct osmo_cbsp_decoded *dec);
|
int cbc_cbsp_link_rx_cb(struct cbc_cbsp_link *link, struct osmo_cbsp_decoded *dec);
|
||||||
|
|||||||
@@ -47,6 +47,6 @@ struct cbc_sbcap_link *cbc_sbcap_link_alloc(struct cbc_sbcap_mgr *cbc, struct cb
|
|||||||
void cbc_sbcap_link_free(struct cbc_sbcap_link *link);
|
void cbc_sbcap_link_free(struct cbc_sbcap_link *link);
|
||||||
const char *cbc_sbcap_link_name(const struct cbc_sbcap_link *link);
|
const char *cbc_sbcap_link_name(const struct cbc_sbcap_link *link);
|
||||||
int cbc_sbcap_link_open_cli(struct cbc_sbcap_link *link);
|
int cbc_sbcap_link_open_cli(struct cbc_sbcap_link *link);
|
||||||
void cbc_sbcap_link_tx(struct cbc_sbcap_link *link, SBcAP_SBC_AP_PDU_t *pdu);
|
int cbc_sbcap_link_tx(struct cbc_sbcap_link *link, SBcAP_SBC_AP_PDU_t *pdu);
|
||||||
void cbc_sbcap_link_close(struct cbc_sbcap_link *link);
|
void cbc_sbcap_link_close(struct cbc_sbcap_link *link);
|
||||||
int cbc_sbcap_link_rx_cb(struct cbc_sbcap_link *link, SBcAP_SBC_AP_PDU_t *pdu);
|
int cbc_sbcap_link_rx_cb(struct cbc_sbcap_link *link, SBcAP_SBC_AP_PDU_t *pdu);
|
||||||
|
|||||||
@@ -70,8 +70,8 @@ int peer_new_cbc_message(struct cbc_peer *peer, struct cbc_message *cbcmsg)
|
|||||||
peer->name);
|
peer->name);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
cbc_cbsp_link_tx(peer->link.cbsp, cbsp);
|
return cbc_cbsp_link_tx(peer->link.cbsp, cbsp);
|
||||||
break;
|
|
||||||
case CBC_PEER_PROTO_SBcAP:
|
case CBC_PEER_PROTO_SBcAP:
|
||||||
/* skip peers without any current SBc-AP connection */
|
/* skip peers without any current SBc-AP connection */
|
||||||
if (!peer->link.sbcap) {
|
if (!peer->link.sbcap) {
|
||||||
@@ -84,17 +84,16 @@ int peer_new_cbc_message(struct cbc_peer *peer, struct cbc_message *cbcmsg)
|
|||||||
peer->name);
|
peer->name);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
cbc_sbcap_link_tx(peer->link.sbcap, sbcap);
|
return cbc_sbcap_link_tx(peer->link.sbcap, sbcap);
|
||||||
break;
|
|
||||||
case CBC_PEER_PROTO_SABP:
|
case CBC_PEER_PROTO_SABP:
|
||||||
LOGP(DLGLOBAL, LOGL_ERROR, "Sending message to peer proto %s not implemented!\n",
|
LOGP(DLGLOBAL, LOGL_ERROR, "Sending message to peer proto %s not implemented!\n",
|
||||||
get_value_string(cbc_peer_proto_name, peer->proto));
|
get_value_string(cbc_peer_proto_name, peer->proto));
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
OSMO_ASSERT(0);
|
OSMO_ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* receive a new CBC message from the user (REST). Allocates new memory,
|
/* receive a new CBC message from the user (REST). Allocates new memory,
|
||||||
|
|||||||
@@ -318,14 +318,14 @@ static int cbsp_cbc_accept_cb(struct osmo_stream_srv_link *srv_link, int fd)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cbc_cbsp_link_tx(struct cbc_cbsp_link *link, struct osmo_cbsp_decoded *cbsp)
|
int cbc_cbsp_link_tx(struct cbc_cbsp_link *link, struct osmo_cbsp_decoded *cbsp)
|
||||||
{
|
{
|
||||||
struct msgb *msg;
|
struct msgb *msg;
|
||||||
|
|
||||||
if (!link) {
|
if (!link) {
|
||||||
LOGP(DCBSP, LOGL_NOTICE, "Cannot transmit %s: no connection\n",
|
LOGP(DCBSP, LOGL_NOTICE, "Cannot transmit %s: no connection\n",
|
||||||
get_value_string(cbsp_msg_type_names, cbsp->msg_type));
|
get_value_string(cbsp_msg_type_names, cbsp->msg_type));
|
||||||
return ;
|
return -ENOLINK;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGPCC(link, LOGL_INFO, "Transmitting %s\n",
|
LOGPCC(link, LOGL_INFO, "Transmitting %s\n",
|
||||||
@@ -336,13 +336,14 @@ void cbc_cbsp_link_tx(struct cbc_cbsp_link *link, struct osmo_cbsp_decoded *cbsp
|
|||||||
LOGPCC(link, LOGL_ERROR, "Failed to encode CBSP %s: %s\n",
|
LOGPCC(link, LOGL_ERROR, "Failed to encode CBSP %s: %s\n",
|
||||||
get_value_string(cbsp_msg_type_names, cbsp->msg_type), osmo_cbsp_errstr);
|
get_value_string(cbsp_msg_type_names, cbsp->msg_type), osmo_cbsp_errstr);
|
||||||
talloc_free(cbsp);
|
talloc_free(cbsp);
|
||||||
return;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
talloc_free(cbsp);
|
talloc_free(cbsp);
|
||||||
if (link->is_client)
|
if (link->is_client)
|
||||||
osmo_stream_cli_send(link->cli_conn, msg);
|
osmo_stream_cli_send(link->cli_conn, msg);
|
||||||
else
|
else
|
||||||
osmo_stream_srv_send(link->srv_conn, msg);
|
osmo_stream_srv_send(link->srv_conn, msg);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cbc_cbsp_link_close(struct cbc_cbsp_link *link)
|
void cbc_cbsp_link_close(struct cbc_cbsp_link *link)
|
||||||
|
|||||||
@@ -379,27 +379,30 @@ static int sbcap_cbc_accept_cb(struct osmo_stream_srv_link *srv_link, int fd)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cbc_sbcap_link_tx(struct cbc_sbcap_link *link, SBcAP_SBC_AP_PDU_t *pdu)
|
int cbc_sbcap_link_tx(struct cbc_sbcap_link *link, SBcAP_SBC_AP_PDU_t *pdu)
|
||||||
{
|
{
|
||||||
struct msgb *msg;
|
struct msgb *msg;
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
if (!pdu) {
|
if (!pdu) {
|
||||||
LOGP(DSBcAP, LOGL_NOTICE, "Cannot transmit msg: no pdu\n");
|
LOGP(DSBcAP, LOGL_NOTICE, "Cannot transmit msg: no pdu\n");
|
||||||
return;
|
return -ENOMSG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!link) {
|
if (!link) {
|
||||||
LOGP(DSBcAP, LOGL_NOTICE, "Cannot transmit msg %s: no connection\n",
|
LOGP(DSBcAP, LOGL_NOTICE, "Cannot transmit msg %s: no connection\n",
|
||||||
sbcap_pdu_get_name(pdu));
|
sbcap_pdu_get_name(pdu));
|
||||||
return;
|
return -ENOLINK;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGPSBCAPC(link, LOGL_INFO, "Tx msg %s\n",
|
LOGPSBCAPC(link, LOGL_INFO, "Tx msg %s\n",
|
||||||
sbcap_pdu_get_name(pdu));
|
sbcap_pdu_get_name(pdu));
|
||||||
OSMO_ASSERT(link->conn);
|
OSMO_ASSERT(link->conn);
|
||||||
msg = sbcap_encode(pdu);
|
msg = sbcap_encode(pdu);
|
||||||
if (!msg)
|
if (!msg) {
|
||||||
|
rc = -EINVAL;
|
||||||
goto ret_free;
|
goto ret_free;
|
||||||
|
}
|
||||||
LOGPSBCAPC(link, LOGL_DEBUG, "Encoded message %s: %s\n",
|
LOGPSBCAPC(link, LOGL_DEBUG, "Encoded message %s: %s\n",
|
||||||
sbcap_pdu_get_name(pdu), msgb_hexdump(msg));
|
sbcap_pdu_get_name(pdu), msgb_hexdump(msg));
|
||||||
if (link->is_client)
|
if (link->is_client)
|
||||||
@@ -408,6 +411,7 @@ void cbc_sbcap_link_tx(struct cbc_sbcap_link *link, SBcAP_SBC_AP_PDU_t *pdu)
|
|||||||
osmo_stream_srv_send(link->srv_conn, msg);
|
osmo_stream_srv_send(link->srv_conn, msg);
|
||||||
ret_free:
|
ret_free:
|
||||||
sbcap_pdu_free(pdu);
|
sbcap_pdu_free(pdu);
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cbc_sbcap_link_close(struct cbc_sbcap_link *link)
|
void cbc_sbcap_link_close(struct cbc_sbcap_link *link)
|
||||||
|
|||||||
Reference in New Issue
Block a user