lists.osmocom.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
June
May
April
March
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
List overview
Download
gerrit-log
July 2022
----- 2025 -----
June 2025
May 2025
April 2025
March 2025
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
gerrit-log@lists.osmocom.org
3 participants
2175 discussions
Start a n
N
ew thread
Change in osmo-cbc[master]: sbcap: Fix typo in sbcap_cause_vals
by laforge
laforge has submitted this change. (
https://gerrit.osmocom.org/c/osmo-cbc/+/28799
) Change subject: sbcap: Fix typo in sbcap_cause_vals ...................................................................... sbcap: Fix typo in sbcap_cause_vals Change-Id: I519a86e5292c39bf1ad502c587838e7b62a0e64f --- M src/sbcap/sbcap_common.c 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved fixeria: Looks good to me, approved diff --git a/src/sbcap/sbcap_common.c b/src/sbcap/sbcap_common.c index a8967ad..3968c71 100644 --- a/src/sbcap/sbcap_common.c +++ b/src/sbcap/sbcap_common.c @@ -36,7 +36,7 @@ { SBcAP_Cause_parameter_value_invalid, "parameter value invalid" }, { SBcAP_Cause_valid_message_not_identified, "valid message not identified" }, { SBcAP_Cause_tracking_area_not_valid, "Tracking Area not valid" }, - { SBcAP_Cause_unrecognised_message, "unrecoznied message" }, + { SBcAP_Cause_unrecognised_message, "unrecognised message" }, { SBcAP_Cause_missing_mandatory_element, "missing mandatory element" }, { SBcAP_Cause_mME_capacity_exceeded, "MME capacity exceeded" }, { SBcAP_Cause_mME_memory_exceeded, "MME memory exceeded" }, -- To view, visit
https://gerrit.osmocom.org/c/osmo-cbc/+/28799
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-cbc Gerrit-Branch: master Gerrit-Change-Id: I519a86e5292c39bf1ad502c587838e7b62a0e64f Gerrit-Change-Number: 28799 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
2 years, 11 months
1
0
0
0
Change in osmo-cbc[master]: sbcap: Send Error Indication if decoding rx msg fails
by laforge
laforge has submitted this change. (
https://gerrit.osmocom.org/c/osmo-cbc/+/28800
) Change subject: sbcap: Send Error Indication if decoding rx msg fails ...................................................................... sbcap: Send Error Indication if decoding rx msg fails Change-Id: I444290f3d697e7485e04eaa38acd8fc3623e0eab --- M include/osmocom/cbc/sbcap_msg.h M include/osmocom/sbcap/sbcap_common.h M src/sbcap/sbcap_common.c M src/sbcap_link.c M src/sbcap_msg.c 5 files changed, 101 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved fixeria: Looks good to me, but someone else must approve diff --git a/include/osmocom/cbc/sbcap_msg.h b/include/osmocom/cbc/sbcap_msg.h index 285c35c..286642c 100644 --- a/include/osmocom/cbc/sbcap_msg.h +++ b/include/osmocom/cbc/sbcap_msg.h @@ -1,6 +1,7 @@ #pragma once #include <osmocom/core/linuxlist.h> #include <osmocom/netif/stream.h> +#include <osmocom/sbcap/sbcap_common.h> #include "cbc_data.h" @@ -9,3 +10,4 @@ SBcAP_SBC_AP_PDU_t *sbcap_gen_write_replace_warning_req(void *ctx, const struct cbc_message *cbcmsg); SBcAP_SBC_AP_PDU_t *sbcap_gen_stop_warning_req(void *ctx, const struct cbc_message *cbcmsg); +SBcAP_SBC_AP_PDU_t *sbcap_gen_error_ind(void *ctx, SBcAP_Cause_t cause, SBcAP_SBC_AP_PDU_t *rx_pdu); diff --git a/include/osmocom/sbcap/sbcap_common.h b/include/osmocom/sbcap/sbcap_common.h index 795bf25..303cf6d 100644 --- a/include/osmocom/sbcap/sbcap_common.h +++ b/include/osmocom/sbcap/sbcap_common.h @@ -141,8 +141,14 @@ void sbcap_set_log_area(int log_area); +SBcAP_ProcedureCode_t sbcap_pdu_get_procedure_code(const SBcAP_SBC_AP_PDU_t *pdu); +SBcAP_Criticality_t sbcap_pdu_get_criticality(const SBcAP_SBC_AP_PDU_t *pdu); + SBcAP_Write_Replace_Warning_Request_IEs_t *sbcap_alloc_Write_Replace_Warning_Request_IE( long id, SBcAP_Criticality_t criticality, SBcAP_Write_Replace_Warning_Request_IEs__value_PR present); SBcAP_Stop_Warning_Request_IEs_t *sbcap_alloc_Stop_Warning_Request_IE( long id, SBcAP_Criticality_t criticality, SBcAP_Stop_Warning_Request_IEs__value_PR present); + +SBcAP_ErrorIndicationIEs_t *sbcap_alloc_Error_Indication_IE( + long id, SBcAP_Criticality_t criticality, SBcAP_Stop_Warning_Request_IEs__value_PR present); diff --git a/src/sbcap/sbcap_common.c b/src/sbcap/sbcap_common.c index 3968c71..86ca0b2 100644 --- a/src/sbcap/sbcap_common.c +++ b/src/sbcap/sbcap_common.c @@ -111,6 +111,36 @@ ASN_STRUCT_FREE(asn_DEF_SBcAP_SBC_AP_PDU, pdu); } +SBcAP_ProcedureCode_t sbcap_pdu_get_procedure_code(const SBcAP_SBC_AP_PDU_t *pdu) +{ + switch (pdu->present) { + case SBcAP_SBC_AP_PDU_PR_initiatingMessage: + return pdu->choice.initiatingMessage.procedureCode; + case SBcAP_SBC_AP_PDU_PR_successfulOutcome: + return pdu->choice.successfulOutcome.procedureCode; + case SBcAP_SBC_AP_PDU_PR_unsuccessfulOutcome: + return pdu->choice.unsuccessfulOutcome.procedureCode; + case SBcAP_SBC_AP_PDU_PR_NOTHING: + default: + return -1; + } +} + +SBcAP_Criticality_t sbcap_pdu_get_criticality(const SBcAP_SBC_AP_PDU_t *pdu) +{ + switch (pdu->present) { + case SBcAP_SBC_AP_PDU_PR_initiatingMessage: + return pdu->choice.initiatingMessage.criticality; + case SBcAP_SBC_AP_PDU_PR_successfulOutcome: + return pdu->choice.successfulOutcome.criticality; + case SBcAP_SBC_AP_PDU_PR_unsuccessfulOutcome: + return pdu->choice.unsuccessfulOutcome.criticality; + case SBcAP_SBC_AP_PDU_PR_NOTHING: + default: + return -1; + } +} + void sbcap_set_log_area(int log_area) { _sbcap_DSBCAP = log_area; @@ -135,3 +165,13 @@ ie->value.present = present; return ie; } + +SBcAP_ErrorIndicationIEs_t *sbcap_alloc_Error_Indication_IE( + long id, SBcAP_Criticality_t criticality, SBcAP_Stop_Warning_Request_IEs__value_PR present) +{ + SBcAP_ErrorIndicationIEs_t *ie = CALLOC(1, sizeof(*ie)); + ie->id = id; + ie->criticality = criticality; + ie->value.present = present; + return ie; +} diff --git a/src/sbcap_link.c b/src/sbcap_link.c index 6459c58..8a3af59 100644 --- a/src/sbcap_link.c +++ b/src/sbcap_link.c @@ -39,6 +39,7 @@ #include <osmocom/cbc/cbc_data.h> #include <osmocom/cbc/sbcap_link.h> #include <osmocom/cbc/sbcap_link_fsm.h> +#include <osmocom/cbc/sbcap_msg.h> #include <osmocom/cbc/cbc_peer.h> #include <osmocom/cbc/debug.h> @@ -166,6 +167,13 @@ g_cbc->sbcap.mgr->rx_cb(link, pdu); } else { LOGPSBCAPC(link, LOGL_ERROR, "Unable to decode %s\n", msgb_hexdump(msg)); + pdu = sbcap_gen_error_ind(link, SBcAP_Cause_unrecognised_message, NULL); + if (pdu) { + cbc_sbcap_link_tx(link, pdu); + } else { + LOGPSBCAPC(link, LOGL_ERROR, + "Tx SBc-AP Error-Indication: msg gen failed\n"); + } } out: msgb_free(msg); diff --git a/src/sbcap_msg.c b/src/sbcap_msg.c index 8f597b2..bd83045 100644 --- a/src/sbcap_msg.c +++ b/src/sbcap_msg.c @@ -291,3 +291,48 @@ return pdu; } + +/* generate a SBc-AP ERROR INDICATION, 3GPP TS 29.168 4.3.4.2A.1. + * rx_pdu can be NULL. + */ +SBcAP_SBC_AP_PDU_t *sbcap_gen_error_ind(void *ctx, SBcAP_Cause_t cause, SBcAP_SBC_AP_PDU_t *rx_pdu) +{ + SBcAP_SBC_AP_PDU_t *pdu; + SBcAP_ErrorIndicationIEs_t *ie; + + pdu = sbcap_pdu_alloc(); + if (!pdu) + return NULL; + pdu->present = SBcAP_SBC_AP_PDU_PR_initiatingMessage; + pdu->choice.initiatingMessage.procedureCode = SBcAP_ProcedureId_Error_Indication; + pdu->choice.initiatingMessage.criticality = SBcAP_Criticality_ignore; + pdu->choice.initiatingMessage.value.present = SBcAP_InitiatingMessage__value_PR_Error_Indication; + + A_SEQUENCE_OF(void) *as_pdu = (void *)&pdu->choice.initiatingMessage.value.choice.Error_Indication.protocolIEs.list; + + /* Cause, Optional: + * 3GPP TS 36.413 4.3.4.3.2 + * static const long asn_VAL_19_SBcAP_id_Cause = 1; */ + ie = sbcap_alloc_Error_Indication_IE(1, SBcAP_Criticality_ignore, + SBcAP_ErrorIndicationIEs__value_PR_Cause); + ie->value.choice.Cause = cause; + ASN_SEQUENCE_ADD(as_pdu, ie); + + if (rx_pdu) { + SBcAP_Criticality_Diagnostics_t *diag_ie; + /* Criticality Diagnostics, Optional: + * 3GPP TS 36.413 4.3.4.3.3 + * static const long asn_VAL_20_SBcAP_id_Criticality_Diagnostics = 2; */ + ie = sbcap_alloc_Error_Indication_IE(1, SBcAP_Criticality_ignore, + SBcAP_ErrorIndicationIEs__value_PR_Criticality_Diagnostics); + diag_ie = &ie->value.choice.Criticality_Diagnostics; + diag_ie->procedureCode = MALLOC(sizeof(*diag_ie->procedureCode)); + *diag_ie->procedureCode = sbcap_pdu_get_procedure_code(rx_pdu); + diag_ie->triggeringMessage = MALLOC(sizeof(*diag_ie->triggeringMessage)); + *diag_ie->triggeringMessage = rx_pdu->present; + diag_ie->procedureCriticality = MALLOC(sizeof(*diag_ie->procedureCriticality)); + *diag_ie->procedureCriticality = sbcap_pdu_get_criticality(rx_pdu); + ASN_SEQUENCE_ADD(as_pdu, ie); + } + return pdu; +} -- To view, visit
https://gerrit.osmocom.org/c/osmo-cbc/+/28800
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-cbc Gerrit-Branch: master Gerrit-Change-Id: I444290f3d697e7485e04eaa38acd8fc3623e0eab Gerrit-Change-Number: 28800 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
2 years, 11 months
1
0
0
0
Change in osmo-cbc[master]: sbcap: Drop unused events
by laforge
laforge has submitted this change. (
https://gerrit.osmocom.org/c/osmo-cbc/+/28801
) Change subject: sbcap: Drop unused events ...................................................................... sbcap: Drop unused events Those events doesn't exist in SBc-AP. Change-Id: Ie4843ed5debbd4282df487ada9596b4d75f4b46c --- M include/osmocom/cbc/sbcap_link_fsm.h M src/sbcap_link_fsm.c 2 files changed, 1 insertion(+), 7 deletions(-) Approvals: Jenkins Builder: Verified dexter: Looks good to me, but someone else must approve laforge: Looks good to me, approved fixeria: Looks good to me, but someone else must approve diff --git a/include/osmocom/cbc/sbcap_link_fsm.h b/include/osmocom/cbc/sbcap_link_fsm.h index e41f1d2..48b4f41 100644 --- a/include/osmocom/cbc/sbcap_link_fsm.h +++ b/include/osmocom/cbc/sbcap_link_fsm.h @@ -6,10 +6,7 @@ extern struct osmo_fsm sbcap_link_fsm; enum sbcap_link_event { - SBcAP_LINK_E_RX_RST_COMPL, /* reset complete received */ - SBcAP_LINK_E_RX_RST_FAIL, /* reset failure received */ - SBcAP_LINK_E_RX_KA_COMPL, /* keep-alive complete received */ - SBcAP_LINK_E_RX_RESTART, /* restart received */ + SBcAP_LINK_E_RX_RESTART, /* SBc-AP PWS Restart Ind received */ SBcAP_LINK_E_CMD_RESET, /* RESET command from CBC */ SBcAP_LINK_E_CMD_CLOSE, /* CLOSE command from CBC */ }; diff --git a/src/sbcap_link_fsm.c b/src/sbcap_link_fsm.c index 0c66a62..d4d10f2 100644 --- a/src/sbcap_link_fsm.c +++ b/src/sbcap_link_fsm.c @@ -42,9 +42,6 @@ }; static const struct value_string sbcap_link_event_names[] = { - { SBcAP_LINK_E_RX_RST_COMPL, "Rx Reset Complete" }, - { SBcAP_LINK_E_RX_RST_FAIL, "Rx Reset Failure" }, - { SBcAP_LINK_E_RX_KA_COMPL, "Rx Keep-Alive Complete" }, { SBcAP_LINK_E_RX_RESTART, "Rx Restart" }, { SBcAP_LINK_E_CMD_RESET, "RESET.cmd" }, { SBcAP_LINK_E_CMD_CLOSE, "CLOSE.cmd" }, -- To view, visit
https://gerrit.osmocom.org/c/osmo-cbc/+/28801
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-cbc Gerrit-Branch: master Gerrit-Change-Id: Ie4843ed5debbd4282df487ada9596b4d75f4b46c Gerrit-Change-Number: 28801 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
2 years, 11 months
1
0
0
0
Change in osmo-cbc[master]: Rename functions generating CBSP/SBc-AP Write-Replace request
by laforge
laforge has submitted this change. (
https://gerrit.osmocom.org/c/osmo-cbc/+/28798
) Change subject: Rename functions generating CBSP/SBc-AP Write-Replace request ...................................................................... Rename functions generating CBSP/SBc-AP Write-Replace request Previous naming is misleading, as it seems to indicate the function is used to generate any kind of message, which is wrong. Change-Id: Ib0228c64bbf104accdbbebb6076004a6a1f44c6f --- M include/osmocom/cbc/cbsp_msg.h M include/osmocom/cbc/sbcap_msg.h M src/cbc_message.c M src/cbsp_msg.c M src/sbcap_msg.c 5 files changed, 6 insertions(+), 6 deletions(-) Approvals: Jenkins Builder: Verified dexter: Looks good to me, approved laforge: Looks good to me, approved diff --git a/include/osmocom/cbc/cbsp_msg.h b/include/osmocom/cbc/cbsp_msg.h index d64d355..c462af4 100644 --- a/include/osmocom/cbc/cbsp_msg.h +++ b/include/osmocom/cbc/cbsp_msg.h @@ -2,4 +2,4 @@ #include <osmocom/gsm/cbsp.h> struct cbc_message; -struct osmo_cbsp_decoded *cbcmsg_to_cbsp(void *ctx, const struct cbc_message *cbcmsg); +struct osmo_cbsp_decoded *cbsp_gen_write_replace_req(void *ctx, const struct cbc_message *cbcmsg); diff --git a/include/osmocom/cbc/sbcap_msg.h b/include/osmocom/cbc/sbcap_msg.h index 784938d..285c35c 100644 --- a/include/osmocom/cbc/sbcap_msg.h +++ b/include/osmocom/cbc/sbcap_msg.h @@ -7,5 +7,5 @@ struct cbc_message; typedef struct SBcAP_SBC_AP_PDU SBcAP_SBC_AP_PDU_t; -SBcAP_SBC_AP_PDU_t *cbcmsg_to_sbcap(void *ctx, const struct cbc_message *cbcmsg); +SBcAP_SBC_AP_PDU_t *sbcap_gen_write_replace_warning_req(void *ctx, const struct cbc_message *cbcmsg); SBcAP_SBC_AP_PDU_t *sbcap_gen_stop_warning_req(void *ctx, const struct cbc_message *cbcmsg); diff --git a/src/cbc_message.c b/src/cbc_message.c index 8884b6c..029abcb 100644 --- a/src/cbc_message.c +++ b/src/cbc_message.c @@ -65,7 +65,7 @@ peer->name); return -ENOTCONN; } - if (!(cbsp = cbcmsg_to_cbsp(peer, cbcmsg))) { + if (!(cbsp = cbsp_gen_write_replace_req(peer, cbcmsg))) { LOGP(DCBSP, LOGL_ERROR, "[%s] Tx CBSP: msg gen failed\n", peer->name); return -EINVAL; @@ -79,7 +79,7 @@ peer->name); return -ENOTCONN; } - if (!(sbcap = cbcmsg_to_sbcap(peer, cbcmsg))) { + if (!(sbcap = sbcap_gen_write_replace_warning_req(peer, cbcmsg))) { LOGP(DSBcAP, LOGL_ERROR, "[%s] Tx SBc-AP: msg gen failed\n", peer->name); return -EINVAL; diff --git a/src/cbsp_msg.c b/src/cbsp_msg.c index 4d0f8d3..de8d852 100644 --- a/src/cbsp_msg.c +++ b/src/cbsp_msg.c @@ -50,7 +50,7 @@ } /* generate a CBSP WRITE-REPLACE from our internal representation */ -struct osmo_cbsp_decoded *cbcmsg_to_cbsp(void *ctx, const struct cbc_message *cbcmsg) +struct osmo_cbsp_decoded *cbsp_gen_write_replace_req(void *ctx, const struct cbc_message *cbcmsg) { struct osmo_cbsp_write_replace *wrepl; const struct smscb_message *smscb = &cbcmsg->msg; diff --git a/src/sbcap_msg.c b/src/sbcap_msg.c index 511036f..8f597b2 100644 --- a/src/sbcap_msg.c +++ b/src/sbcap_msg.c @@ -84,7 +84,7 @@ /* generate a SBc-AP WRITE-REPLACE WARNING REQUEST from our internal representation. * 3GPP TS 36.413 9.1.13.1 */ -SBcAP_SBC_AP_PDU_t *cbcmsg_to_sbcap(void *ctx, const struct cbc_message *cbcmsg) +SBcAP_SBC_AP_PDU_t *sbcap_gen_write_replace_warning_req(void *ctx, const struct cbc_message *cbcmsg) { const struct smscb_message *smscb = &cbcmsg->msg; SBcAP_SBC_AP_PDU_t *pdu; -- To view, visit
https://gerrit.osmocom.org/c/osmo-cbc/+/28798
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-cbc Gerrit-Branch: master Gerrit-Change-Id: Ib0228c64bbf104accdbbebb6076004a6a1f44c6f Gerrit-Change-Number: 28798 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
2 years, 11 months
1
0
0
0
Change in osmo-cbc[master]: vty: Fix typo in vty output
by laforge
laforge has submitted this change. (
https://gerrit.osmocom.org/c/osmo-cbc/+/28796
) Change subject: vty: Fix typo in vty output ...................................................................... vty: Fix typo in vty output Change-Id: I601f9ebcf17c5129edbce5b3ac7f0fd8294dd572 --- M src/cbc_vty.c 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: Jenkins Builder: Verified fixeria: Looks good to me, approved laforge: Looks good to me, approved diff --git a/src/cbc_vty.c b/src/cbc_vty.c index bb445b3..1f19878 100644 --- a/src/cbc_vty.c +++ b/src/cbc_vty.c @@ -247,7 +247,7 @@ if (!cbc_msg) cbc_msg = cbc_message_expired_by_id(msgid); if (!cbc_msg) { - vty_out(vty, "Unknown Messsage ID %s%s", argv[0], VTY_NEWLINE); + vty_out(vty, "Unknown Message ID %s%s", argv[0], VTY_NEWLINE); return CMD_WARNING; } smscb = &cbc_msg->msg; -- To view, visit
https://gerrit.osmocom.org/c/osmo-cbc/+/28796
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-cbc Gerrit-Branch: master Gerrit-Change-Id: I601f9ebcf17c5129edbce5b3ac7f0fd8294dd572 Gerrit-Change-Number: 28796 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
2 years, 11 months
1
0
0
0
Change in osmo-cbc[master]: sbcap_msg: Improve spec references for used IEs
by laforge
laforge has submitted this change. (
https://gerrit.osmocom.org/c/osmo-cbc/+/28791
) Change subject: sbcap_msg: Improve spec references for used IEs ...................................................................... sbcap_msg: Improve spec references for used IEs Change-Id: I55749aa84415e0af240c3cc46f2b274e1d24e403 --- M src/sbcap_msg.c 1 file changed, 43 insertions(+), 17 deletions(-) Approvals: Jenkins Builder: Verified fixeria: Looks good to me, approved laforge: Looks good to me, approved diff --git a/src/sbcap_msg.c b/src/sbcap_msg.c index 7dc3410..511036f 100644 --- a/src/sbcap_msg.c +++ b/src/sbcap_msg.c @@ -35,10 +35,13 @@ #include <osmocom/cbc/sbcap_link.h> #include <osmocom/cbc/debug.h> -/* 3GPP TS 36.413 9.2.1.53 */ +/* 3GPP TS 36.413 9.2.1.53, 3GPP TS 23.041 9.3.35 */ #define SBCAP_WARN_MSG_CONTENTS_IE_MAX_LEN 9600 #if 0 +/* Warning Area List + * 3GPP TS 36.413 9.2.1.46, 3GPP TS 23.041 9.3.30 + */ static void msgb_put_sbcap_cell_list(const struct cbc_message *cbcmsg, void *void_li) { static uint8_t ie_plm_id0[] = {0x05, 0xf5, 0x32}; @@ -78,7 +81,9 @@ } #endif -/* generate a SBc-AP WRITE-REPLACE WARNING REQUEST from our internal representation */ +/* generate a SBc-AP WRITE-REPLACE WARNING REQUEST from our internal representation. + * 3GPP TS 36.413 9.1.13.1 + */ SBcAP_SBC_AP_PDU_t *cbcmsg_to_sbcap(void *ctx, const struct cbc_message *cbcmsg) { const struct smscb_message *smscb = &cbcmsg->msg; @@ -100,7 +105,9 @@ A_SEQUENCE_OF(void) *as_pdu = (void *)&pdu->choice.initiatingMessage.value.choice.Write_Replace_Warning_Request.protocolIEs.list; - /* static const long asn_VAL_1_SBcAP_id_Message_Identifier = 5; */ + /* Message Identifier: + * 3GPP TS 36.413 9.2.1.44, 3GPP TS 23.041 9.4.1.3.6 + * static const long asn_VAL_1_SBcAP_id_Message_Identifier = 5; */ ie = sbcap_alloc_Write_Replace_Warning_Request_IE(5, SBcAP_Criticality_reject, SBcAP_Write_Replace_Warning_Request_IEs__value_PR_Message_Identifier); ie->value.choice.Message_Identifier.buf = MALLOC(sizeof(uint16_t)); @@ -109,7 +116,9 @@ osmo_store16be(smscb->message_id, ie->value.choice.Message_Identifier.buf); ASN_SEQUENCE_ADD(as_pdu, ie); - /* static const long asn_VAL_2_SBcAP_id_Serial_Number = 11; */ + /* Serial Number + * 3GPP TS 36.413 9.2.1.45, 3GPP TS 23.041 9.4.1.2.1 + * static const long asn_VAL_2_SBcAP_id_Serial_Number = 11; */ ie = sbcap_alloc_Write_Replace_Warning_Request_IE(11, SBcAP_Criticality_reject, SBcAP_Write_Replace_Warning_Request_IEs__value_PR_Serial_Number); ie->value.choice.Serial_Number.buf = MALLOC(sizeof(uint16_t)); @@ -123,7 +132,9 @@ break; /* Nothing to be done :*/ #if 0 case CBC_MSG_SCOPE_EUTRAN_CGI: - /* static const long asn_VAL_25_SBcAP_id_Warning_Area_List = 15; */ + /* Warning Area List + * 3GPP TS 36.413 9.2.1.46, 3GPP TS 23.041 9.3.30 + * static const long asn_VAL_25_SBcAP_id_Warning_Area_List = 15; */ ie = sbcap_alloc_Write_Replace_Warning_Request_IE(15, SBcAP_Criticality_ignore, SBcAP_Write_Replace_Warning_Request_IEs__value_PR_Warning_Area_List); ASN_SEQUENCE_ADD(as_pdu, ie); @@ -135,21 +146,26 @@ OSMO_ASSERT(0); } - /* static const long asn_VAL_5_SBcAP_id_Repetition_Period = 10; */ + /* Repetition Period + * 3GPP TS 36.413 9.2.1.48, 3GPP TS 23.041 9.3.8 + * static const long asn_VAL_5_SBcAP_id_Repetition_Period = 10; */ ie = sbcap_alloc_Write_Replace_Warning_Request_IE(10, SBcAP_Criticality_reject, SBcAP_Write_Replace_Warning_Request_IEs__value_PR_Repetition_Period); ie->value.choice.Repetition_Period = cbcmsg->rep_period; /*seconds */ ASN_SEQUENCE_ADD(as_pdu, ie); - /* static const long asn_VAL_7_SBcAP_id_Number_of_Broadcasts_Requested = 7; */ + /* Number of Broadcasts Requested + * 3GPP TS 36.413 9.2.1.49, 3GPP TS 23.041 9.3.9 + * static const long asn_VAL_7_SBcAP_id_Number_of_Broadcasts_Requested = 7; */ ie = sbcap_alloc_Write_Replace_Warning_Request_IE(7, SBcAP_Criticality_reject, SBcAP_Write_Replace_Warning_Request_IEs__value_PR_Number_of_Broadcasts_Requested); ie->value.choice.Number_of_Broadcasts_Requested = cbcmsg->num_bcast; ASN_SEQUENCE_ADD(as_pdu, ie); if (smscb->is_etws) { - /* Warning Type, 3GPP TS 36.413 sec 9.2.1.50: */ - /* static const long asn_VAL_8_SBcAP_id_Warning_Type = 18; */ + /* Warning Type + * 3GPP TS 36.413 sec 9.2.1.50, 3GPP TS 23.041 9.3.24 + * static const long asn_VAL_8_SBcAP_id_Warning_Type = 18; */ ie = sbcap_alloc_Write_Replace_Warning_Request_IE(18, SBcAP_Criticality_ignore, SBcAP_Write_Replace_Warning_Request_IEs__value_PR_Warning_Type); ie->value.choice.Warning_Type.buf = MALLOC(2); @@ -160,8 +176,9 @@ ie->value.choice.Warning_Type.buf[1] = (smscb->etws.popup_on_display) ? 0x80 : 0x0; ASN_SEQUENCE_ADD(as_pdu, ie); - /* Warning Security Information, 3GPP TS 36.413 sec 9.2.1.51: */ - /*static const long asn_VAL_9_SBcAP_id_Warning_Security_Information = 17 */ + /* Warning Security Information + * 3GPP TS 36.413 sec 9.2.1.51, 3GPP TS 23.041 9.3.25 + * static const long asn_VAL_9_SBcAP_id_Warning_Security_Information = 17 */ ie = sbcap_alloc_Write_Replace_Warning_Request_IE(17, SBcAP_Criticality_ignore, SBcAP_Write_Replace_Warning_Request_IEs__value_PR_Warning_Security_Information); ie->value.choice.Warning_Security_Information.buf = MALLOC(sizeof(smscb->etws.warning_sec_info)); @@ -171,7 +188,9 @@ ASN_SEQUENCE_ADD(as_pdu, ie); } else { - /* static const long asn_VAL_10_SBcAP_id_Data_Coding_Scheme = 3; */ + /* Data Coding Scheme + * 3GPP TS 36.413 9.2.1.52, 3GPP TS 23.041 9.4.1.2.3 + * static const long asn_VAL_10_SBcAP_id_Data_Coding_Scheme = 3; */ ie = sbcap_alloc_Write_Replace_Warning_Request_IE(3, SBcAP_Criticality_ignore, SBcAP_Write_Replace_Warning_Request_IEs__value_PR_Data_Coding_Scheme); ie->value.choice.Data_Coding_Scheme.buf = MALLOC(1); @@ -180,8 +199,9 @@ *ie->value.choice.Data_Coding_Scheme.buf = smscb->cbs.dcs; ASN_SEQUENCE_ADD(as_pdu, ie); - /* 3GPP TS 36.413 9.2.1.53 Warning Message Contents. Encoded as in S1AP. */ - /* static const long asn_VAL_11_SBcAP_id_Warning_Message_Content = 16; */ + /* Warning Message Contents + * 3GPP TS 36.413 9.2.1.53, 3GPP TS 23.041 9.3.35 + * static const long asn_VAL_11_SBcAP_id_Warning_Message_Content = 16; */ ie = sbcap_alloc_Write_Replace_Warning_Request_IE(16, SBcAP_Criticality_ignore, SBcAP_Write_Replace_Warning_Request_IEs__value_PR_Warning_Message_Content); ie->value.choice.Warning_Message_Content.buf = MALLOC(1 + smscb->cbs.num_pages * (SMSCB_RAW_PAGE_LEN+1)); @@ -228,7 +248,9 @@ A_SEQUENCE_OF(void) *as_pdu = (void *)&pdu->choice.initiatingMessage.value.choice.Stop_Warning_Request.protocolIEs.list; - /* static const long asn_VAL_1_SBcAP_id_Message_Identifier = 5; */ + /* Message Identifier: + * 3GPP TS 36.413 9.2.1.44, 3GPP TS 23.041 9.4.1.3.6 + * static const long asn_VAL_1_SBcAP_id_Message_Identifier = 5; */ ie = sbcap_alloc_Stop_Warning_Request_IE(5, SBcAP_Criticality_reject, SBcAP_Write_Replace_Warning_Request_IEs__value_PR_Message_Identifier); ie->value.choice.Message_Identifier.buf = MALLOC(sizeof(uint16_t)); @@ -237,7 +259,9 @@ osmo_store16be(smscb->message_id, ie->value.choice.Message_Identifier.buf); ASN_SEQUENCE_ADD(as_pdu, ie); - /* static const long asn_VAL_2_SBcAP_id_Serial_Number = 11; */ + /* Serial Number + * 3GPP TS 36.413 9.2.1.45, 3GPP TS 23.041 9.4.1.2.1 + * static const long asn_VAL_2_SBcAP_id_Serial_Number = 11; */ ie = sbcap_alloc_Stop_Warning_Request_IE(11, SBcAP_Criticality_reject, SBcAP_Write_Replace_Warning_Request_IEs__value_PR_Serial_Number); ie->value.choice.Serial_Number.buf = MALLOC(sizeof(uint16_t)); @@ -251,7 +275,9 @@ break; /* Nothing to be done :*/ #if 0 case CBC_MSG_SCOPE_EUTRAN_CGI: - /* static const long asn_VAL_25_SBcAP_id_Warning_Area_List = 15; */ + /* Warning Area List + * 3GPP TS 36.413 9.2.1.46, 3GPP TS 23.041 9.3.30 + * static const long asn_VAL_25_SBcAP_id_Warning_Area_List = 15; */ ie = sbcap_alloc_Stop_Warning_Request_IE(15, SBcAP_Criticality_ignore, SBcAP_Write_Replace_Warning_Request_IEs__value_PR_Warning_Area_List); ASN_SEQUENCE_ADD(as_pdu, ie); -- To view, visit
https://gerrit.osmocom.org/c/osmo-cbc/+/28791
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-cbc Gerrit-Branch: master Gerrit-Change-Id: I55749aa84415e0af240c3cc46f2b274e1d24e403 Gerrit-Change-Number: 28791 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
2 years, 11 months
1
0
0
0
Change in osmo-cbc[master]: Rearrange cbc_message and cbsp message code
by laforge
laforge has submitted this change. (
https://gerrit.osmocom.org/c/osmo-cbc/+/28797
) Change subject: Rearrange cbc_message and cbsp message code ...................................................................... Rearrange cbc_message and cbsp message code Move code from message_handling containing both code for generic cbc_message and specific cbsp_message into thers files. The former are moved to cbc_message.c and the later to cbsp_msg.c, similar to what's already done for SBc-AP messages. Change-Id: Ie4082e40f23170cfd6c573fbbb7beb8c6226b6e6 --- M include/osmocom/cbc/Makefile.am A include/osmocom/cbc/cbsp_msg.h M src/Makefile.am M src/cbc_message.c A src/cbsp_msg.c D src/message_handling.c 6 files changed, 256 insertions(+), 248 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved; Verified fixeria: Looks good to me, but someone else must approve diff --git a/include/osmocom/cbc/Makefile.am b/include/osmocom/cbc/Makefile.am index b345434..dc3a21f 100644 --- a/include/osmocom/cbc/Makefile.am +++ b/include/osmocom/cbc/Makefile.am @@ -5,6 +5,7 @@ cbc_vty.h \ cbsp_link.h \ cbsp_link_fsm.h \ + cbsp_msg.h \ charset.h \ debug.h \ sbcap_msg.h \ diff --git a/include/osmocom/cbc/cbsp_msg.h b/include/osmocom/cbc/cbsp_msg.h new file mode 100644 index 0000000..d64d355 --- /dev/null +++ b/include/osmocom/cbc/cbsp_msg.h @@ -0,0 +1,5 @@ +#pragma once +#include <osmocom/gsm/cbsp.h> + +struct cbc_message; +struct osmo_cbsp_decoded *cbcmsg_to_cbsp(void *ctx, const struct cbc_message *cbcmsg); diff --git a/src/Makefile.am b/src/Makefile.am index e72b20b..de40dea 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -17,9 +17,9 @@ cbc_vty.c \ cbsp_link.c \ cbsp_link_fsm.c \ + cbsp_msg.c \ rest_api.c \ charset.c \ - message_handling.c \ rest_it_op.c \ sbcap_msg.c \ sbcap_link.c \ diff --git a/src/cbc_message.c b/src/cbc_message.c index c88e907..8884b6c 100644 --- a/src/cbc_message.c +++ b/src/cbc_message.c @@ -27,8 +27,147 @@ #include <osmocom/core/linuxlist.h> #include <osmocom/core/talloc.h> #include <osmocom/core/utils.h> +#include <osmocom/core/logging.h> +#include <osmocom/cbc/cbsp_msg.h> +#include <osmocom/cbc/cbsp_link.h> +#include <osmocom/cbc/sbcap_msg.h> +#include <osmocom/cbc/sbcap_link.h> #include <osmocom/cbc/cbc_message.h> +#include <osmocom/cbc/cbc_peer.h> +#include <osmocom/cbc/debug.h> +#include <osmocom/cbc/rest_it_op.h> +#include <osmocom/cbc/smscb_message_fsm.h> + +/* determine if peer is within scope of cbc_msg */ +static bool is_peer_in_scope(const struct cbc_peer *peer, const struct cbc_message *cbcmsg) +{ + switch (cbcmsg->scope) { + case CBC_MSG_SCOPE_PLMN: + return true; + /* FIXME: differnt scopes */ + default: + OSMO_ASSERT(0); + } +} + +/* send given new message to given peer */ +int peer_new_cbc_message(struct cbc_peer *peer, struct cbc_message *cbcmsg) +{ + struct osmo_cbsp_decoded *cbsp; + SBcAP_SBC_AP_PDU_t *sbcap; + + switch (peer->proto) { + case CBC_PEER_PROTO_CBSP: + /* skip peers without any current CBSP connection */ + if (!peer->link.cbsp) { + LOGP(DCBSP, LOGL_NOTICE, "[%s] Tx CBSP: not connected\n", + peer->name); + return -ENOTCONN; + } + if (!(cbsp = cbcmsg_to_cbsp(peer, cbcmsg))) { + LOGP(DCBSP, LOGL_ERROR, "[%s] Tx CBSP: msg gen failed\n", + peer->name); + return -EINVAL; + } + cbc_cbsp_link_tx(peer->link.cbsp, cbsp); + break; + case CBC_PEER_PROTO_SBcAP: + /* skip peers without any current SBc-AP connection */ + if (!peer->link.sbcap) { + LOGP(DSBcAP, LOGL_NOTICE, "[%s] Tx SBc-AP: not connected\n", + peer->name); + return -ENOTCONN; + } + if (!(sbcap = cbcmsg_to_sbcap(peer, cbcmsg))) { + LOGP(DSBcAP, LOGL_ERROR, "[%s] Tx SBc-AP: msg gen failed\n", + peer->name); + return -EINVAL; + } + cbc_sbcap_link_tx(peer->link.sbcap, sbcap); + break; + case CBC_PEER_PROTO_SABP: + LOGP(DLGLOBAL, LOGL_ERROR, "Sending message to peer proto %s not implemented!\n", + get_value_string(cbc_peer_proto_name, peer->proto)); + return -1; + default: + OSMO_ASSERT(0); + } + + return 0; +} + +/* receive a new CBC message from the user (REST). Allocates new memory, + * a FSM, copies data from 'orig', routes to all peers and starts FSMs. + * Once the operation is complete (success, error, timeout) we must + * notify osmo_it_q of the completion */ +int cbc_message_new(const struct cbc_message *orig, struct rest_it_op *op) +{ + struct cbc_message *cbcmsg = cbc_message_alloc(g_cbc, orig); + struct cbc_peer *peer; + + if (!cbcmsg) { + rest_it_op_set_http_result(op, 409, "Could not allocate"); + rest_it_op_complete(op); + return -ENOMEM; + } + + OSMO_ASSERT(llist_empty(&cbcmsg->peers)); + + /* iterate over all peers */ + llist_for_each_entry(peer, &g_cbc->peers, list) { + struct cbc_message_peer *mp; + + if (!is_peer_in_scope(peer, cbcmsg)) + continue; + + /* allocate new cbc_mesage_peer + related FSM */ + mp = smscb_peer_fsm_alloc(peer, cbcmsg); + if (!mp) { + LOGP(DCBSP, LOGL_ERROR, "Cannot allocate cbc_message_peer\n"); + continue; + } + } + + /* kick off the state machine[s] */ + if (osmo_fsm_inst_dispatch(cbcmsg->fi, SMSCB_E_CREATE, op) < 0) { + rest_it_op_set_http_result(op, 500, "Illegal FSM event"); + rest_it_op_complete(op); + } + + /* we continue in the FSM after the WRITE_ACK event was received */ + + return 0; +} + +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) { + rest_it_op_set_http_result(op, 500, "Illegal FSM event"); + rest_it_op_complete(op); + } + /* we continue in the FSM after the DELETE_ACK event was received */ +} + +struct cbc_message *cbc_message_by_id(uint16_t message_id) +{ + struct cbc_message *cbc_msg; + llist_for_each_entry(cbc_msg, &g_cbc->messages, list) { + if (cbc_msg->msg.message_id == message_id) + return cbc_msg; + } + return NULL; +} + +struct cbc_message *cbc_message_expired_by_id(uint16_t message_id) +{ + struct cbc_message *cbc_msg; + llist_for_each_entry(cbc_msg, &g_cbc->expired_messages, list) { + if (cbc_msg->msg.message_id == message_id) + return cbc_msg; + } + return NULL; +} /* remove a peer from the message */ int cbc_message_del_peer(struct cbc_message *cbcmsg, struct cbc_peer *peer) diff --git a/src/cbsp_msg.c b/src/cbsp_msg.c new file mode 100644 index 0000000..4d0f8d3 --- /dev/null +++ b/src/cbsp_msg.c @@ -0,0 +1,110 @@ +/* Osmocom CBC (Cell Broacast Centre) */ + +/* (C) 2019 by Harald Welte <laforge(a)gnumonks.org> + * All Rights Reserved + * + * SPDX-License-Identifier: AGPL-3.0+ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <
http://www.gnu.org/licenses/
>. + * + */ + + +#include <errno.h> + +#include <osmocom/core/linuxlist.h> +#include <osmocom/core/utils.h> +#include <osmocom/gsm/cbsp.h> +#include <osmocom/cbc/cbsp_msg.h> +#include <osmocom/cbc/cbc_message.h> + +/* convert cbc_message to osmo_cbsp_cell_list */ +static int cbcmsg_to_cbsp_cell_list(const void *ctx, struct osmo_cbsp_cell_list *list, + const struct cbc_message *cbcmsg) +{ + struct osmo_cbsp_cell_ent *ent; + + switch (cbcmsg->scope) { + case CBC_MSG_SCOPE_PLMN: + list->id_discr = CELL_IDENT_BSS; + ent = talloc_zero(ctx, struct osmo_cbsp_cell_ent); + if (!ent) + return -ENOMEM; + //ent->cell_id = ? + llist_add_tail(&ent->list, &list->list); + return 0; + default: + OSMO_ASSERT(0); + } +} + +/* generate a CBSP WRITE-REPLACE from our internal representation */ +struct osmo_cbsp_decoded *cbcmsg_to_cbsp(void *ctx, const struct cbc_message *cbcmsg) +{ + struct osmo_cbsp_write_replace *wrepl; + const struct smscb_message *smscb = &cbcmsg->msg; + struct osmo_cbsp_decoded *cbsp = osmo_cbsp_decoded_alloc(ctx, CBSP_MSGT_WRITE_REPLACE); + unsigned int i; + int rc; + + if (!cbsp) + return NULL; + wrepl = &cbsp->u.write_replace; + + wrepl->msg_id = smscb->message_id; + wrepl->new_serial_nr = smscb->serial_nr; + /* FIXME: old? */ + /* Cell list */ + rc = cbcmsg_to_cbsp_cell_list(cbcmsg, &wrepl->cell_list, cbcmsg); + if (rc < 0) { + talloc_free(cbsp); + return NULL; + } + if (!smscb->is_etws) + wrepl->is_cbs = true; + if (wrepl->is_cbs) { + if (cbcmsg->extended_cbch) + wrepl->u.cbs.channel_ind = CBSP_CHAN_IND_EXTENDED; + else + wrepl->u.cbs.channel_ind = CBSP_CHAN_IND_BASIC; + wrepl->u.cbs.category = cbcmsg->priority; + wrepl->u.cbs.rep_period = cbcmsg->rep_period; + wrepl->u.cbs.num_bcast_req = cbcmsg->num_bcast; + wrepl->u.cbs.dcs = smscb->cbs.dcs; + INIT_LLIST_HEAD(&wrepl->u.cbs.msg_content); + for (i = 0; i < smscb->cbs.num_pages; i++) { + struct osmo_cbsp_content *ce = talloc_zero(cbsp, struct osmo_cbsp_content); + if (i == smscb->cbs.num_pages - 1) + ce->user_len = smscb->cbs.data_user_len - (i * SMSCB_RAW_PAGE_LEN); + else + ce->user_len = SMSCB_RAW_PAGE_LEN; + memcpy(ce->data, smscb->cbs.data[i], SMSCB_RAW_PAGE_LEN); + llist_add_tail(&ce->list, &wrepl->u.cbs.msg_content); + } + } else { + wrepl->u.emergency.indicator = 1; + wrepl->u.emergency.warning_type = (smscb->etws.warning_type & 0x7f) << 9; + if (smscb->etws.user_alert) + wrepl->u.emergency.warning_type |= 0x0100; + if (smscb->etws.popup_on_display) + wrepl->u.emergency.warning_type |= 0x0080; + memcpy(wrepl->u.emergency.warning_sec_info, smscb->etws.warning_sec_info, + sizeof(wrepl->u.emergency.warning_sec_info)); + if (cbcmsg->warning_period_sec == 0xffffffff) + wrepl->u.emergency.warning_period = 0; + else + wrepl->u.emergency.warning_period = cbcmsg->warning_period_sec; + } + return cbsp; +} diff --git a/src/message_handling.c b/src/message_handling.c deleted file mode 100644 index 76739c3..0000000 --- a/src/message_handling.c +++ /dev/null @@ -1,247 +0,0 @@ -/* Osmocom CBC (Cell Broacast Centre) */ - -/* (C) 2019 by Harald Welte <laforge(a)gnumonks.org> - * All Rights Reserved - * - * SPDX-License-Identifier: AGPL-3.0+ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <
http://www.gnu.org/licenses/
>. - * - */ - - -#include <errno.h> - -#include <osmocom/core/linuxlist.h> -#include <osmocom/core/utils.h> -#include <osmocom/gsm/cbsp.h> - -#include <osmocom/cbc/cbc_data.h> -#include <osmocom/cbc/cbsp_link.h> -#include <osmocom/cbc/sbcap_link.h> -#include <osmocom/cbc/sbcap_msg.h> -#include <osmocom/cbc/rest_it_op.h> -#include <osmocom/cbc/debug.h> -#include <osmocom/cbc/cbc_peer.h> -#include <osmocom/cbc/smscb_message_fsm.h> - -/* convert cbc_message to osmo_cbsp_cell_list */ -static int cbcmsg_to_cbsp_cell_list(const void *ctx, struct osmo_cbsp_cell_list *list, - const struct cbc_message *cbcmsg) -{ - struct osmo_cbsp_cell_ent *ent; - - switch (cbcmsg->scope) { - case CBC_MSG_SCOPE_PLMN: - list->id_discr = CELL_IDENT_BSS; - ent = talloc_zero(ctx, struct osmo_cbsp_cell_ent); - if (!ent) - return -ENOMEM; - //ent->cell_id = ? - llist_add_tail(&ent->list, &list->list); - return 0; - default: - OSMO_ASSERT(0); - } -} - -/* generate a CBSP WRITE-REPLACE from our internal representation */ -struct osmo_cbsp_decoded *cbcmsg_to_cbsp(void *ctx, const struct cbc_message *cbcmsg) -{ - struct osmo_cbsp_write_replace *wrepl; - const struct smscb_message *smscb = &cbcmsg->msg; - struct osmo_cbsp_decoded *cbsp = osmo_cbsp_decoded_alloc(ctx, CBSP_MSGT_WRITE_REPLACE); - unsigned int i; - int rc; - - if (!cbsp) - return NULL; - wrepl = &cbsp->u.write_replace; - - wrepl->msg_id = smscb->message_id; - wrepl->new_serial_nr = smscb->serial_nr; - /* FIXME: old? */ - /* Cell list */ - rc = cbcmsg_to_cbsp_cell_list(cbcmsg, &wrepl->cell_list, cbcmsg); - if (rc < 0) { - talloc_free(cbsp); - return NULL; - } - if (!smscb->is_etws) - wrepl->is_cbs = true; - if (wrepl->is_cbs) { - if (cbcmsg->extended_cbch) - wrepl->u.cbs.channel_ind = CBSP_CHAN_IND_EXTENDED; - else - wrepl->u.cbs.channel_ind = CBSP_CHAN_IND_BASIC; - wrepl->u.cbs.category = cbcmsg->priority; - wrepl->u.cbs.rep_period = cbcmsg->rep_period; - wrepl->u.cbs.num_bcast_req = cbcmsg->num_bcast; - wrepl->u.cbs.dcs = smscb->cbs.dcs; - INIT_LLIST_HEAD(&wrepl->u.cbs.msg_content); - for (i = 0; i < smscb->cbs.num_pages; i++) { - struct osmo_cbsp_content *ce = talloc_zero(cbsp, struct osmo_cbsp_content); - if (i == smscb->cbs.num_pages - 1) - ce->user_len = smscb->cbs.data_user_len - (i * SMSCB_RAW_PAGE_LEN); - else - ce->user_len = SMSCB_RAW_PAGE_LEN; - memcpy(ce->data, smscb->cbs.data[i], SMSCB_RAW_PAGE_LEN); - llist_add_tail(&ce->list, &wrepl->u.cbs.msg_content); - } - } else { - wrepl->u.emergency.indicator = 1; - wrepl->u.emergency.warning_type = (smscb->etws.warning_type & 0x7f) << 9; - if (smscb->etws.user_alert) - wrepl->u.emergency.warning_type |= 0x0100; - if (smscb->etws.popup_on_display) - wrepl->u.emergency.warning_type |= 0x0080; - memcpy(wrepl->u.emergency.warning_sec_info, smscb->etws.warning_sec_info, - sizeof(wrepl->u.emergency.warning_sec_info)); - if (cbcmsg->warning_period_sec == 0xffffffff) - wrepl->u.emergency.warning_period = 0; - else - wrepl->u.emergency.warning_period = cbcmsg->warning_period_sec; - } - return cbsp; -} - -/* determine if peer is within scope of cbc_msg */ -static bool is_peer_in_scope(const struct cbc_peer *peer, const struct cbc_message *cbcmsg) -{ - switch (cbcmsg->scope) { - case CBC_MSG_SCOPE_PLMN: - return true; - /* FIXME: differnt scopes */ - default: - OSMO_ASSERT(0); - } -} - -/* send given new message to given peer */ -int peer_new_cbc_message(struct cbc_peer *peer, struct cbc_message *cbcmsg) -{ - struct osmo_cbsp_decoded *cbsp; - SBcAP_SBC_AP_PDU_t *sbcap; - - switch (peer->proto) { - case CBC_PEER_PROTO_CBSP: - /* skip peers without any current CBSP connection */ - if (!peer->link.cbsp) { - LOGP(DCBSP, LOGL_NOTICE, "[%s] Tx CBSP: not connected\n", - peer->name); - return -ENOTCONN; - } - if (!(cbsp = cbcmsg_to_cbsp(peer, cbcmsg))) { - LOGP(DCBSP, LOGL_ERROR, "[%s] Tx CBSP: msg gen failed\n", - peer->name); - return -EINVAL; - } - cbc_cbsp_link_tx(peer->link.cbsp, cbsp); - break; - case CBC_PEER_PROTO_SBcAP: - /* skip peers without any current SBc-AP connection */ - if (!peer->link.sbcap) { - LOGP(DSBcAP, LOGL_NOTICE, "[%s] Tx SBc-AP: not connected\n", - peer->name); - return -ENOTCONN; - } - if (!(sbcap = cbcmsg_to_sbcap(peer, cbcmsg))) { - LOGP(DSBcAP, LOGL_ERROR, "[%s] Tx SBc-AP: msg gen failed\n", - peer->name); - return -EINVAL; - } - cbc_sbcap_link_tx(peer->link.sbcap, sbcap); - break; - case CBC_PEER_PROTO_SABP: - LOGP(DLGLOBAL, LOGL_ERROR, "Sending message to peer proto %s not implemented!\n", - get_value_string(cbc_peer_proto_name, peer->proto)); - return -1; - default: - OSMO_ASSERT(0); - } - - return 0; -} - -/* receive a new CBC message from the user (REST). Allocates new memory, - * a FSM, copies data from 'orig', routes to all peers and starts FSMs. - * Once the operation is complete (success, error, timeout) we must - * notify osmo_it_q of the completion */ -int cbc_message_new(const struct cbc_message *orig, struct rest_it_op *op) -{ - struct cbc_message *cbcmsg = cbc_message_alloc(g_cbc, orig); - struct cbc_peer *peer; - - if (!cbcmsg) { - rest_it_op_set_http_result(op, 409, "Could not allocate"); - rest_it_op_complete(op); - return -ENOMEM; - } - - OSMO_ASSERT(llist_empty(&cbcmsg->peers)); - - /* iterate over all peers */ - llist_for_each_entry(peer, &g_cbc->peers, list) { - struct cbc_message_peer *mp; - - if (!is_peer_in_scope(peer, cbcmsg)) - continue; - - /* allocate new cbc_mesage_peer + related FSM */ - mp = smscb_peer_fsm_alloc(peer, cbcmsg); - if (!mp) { - LOGP(DCBSP, LOGL_ERROR, "Cannot allocate cbc_message_peer\n"); - continue; - } - } - - /* kick off the state machine[s] */ - if (osmo_fsm_inst_dispatch(cbcmsg->fi, SMSCB_E_CREATE, op) < 0) { - rest_it_op_set_http_result(op, 500, "Illegal FSM event"); - rest_it_op_complete(op); - } - - /* we continue in the FSM after the WRITE_ACK event was received */ - - return 0; -} - -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) { - rest_it_op_set_http_result(op, 500, "Illegal FSM event"); - rest_it_op_complete(op); - } - /* we continue in the FSM after the DELETE_ACK event was received */ -} - -struct cbc_message *cbc_message_by_id(uint16_t message_id) -{ - struct cbc_message *cbc_msg; - llist_for_each_entry(cbc_msg, &g_cbc->messages, list) { - if (cbc_msg->msg.message_id == message_id) - return cbc_msg; - } - return NULL; -} - -struct cbc_message *cbc_message_expired_by_id(uint16_t message_id) -{ - struct cbc_message *cbc_msg; - llist_for_each_entry(cbc_msg, &g_cbc->expired_messages, list) { - if (cbc_msg->msg.message_id == message_id) - return cbc_msg; - } - return NULL; -} -- To view, visit
https://gerrit.osmocom.org/c/osmo-cbc/+/28797
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-cbc Gerrit-Branch: master Gerrit-Change-Id: Ie4082e40f23170cfd6c573fbbb7beb8c6226b6e6 Gerrit-Change-Number: 28797 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
2 years, 11 months
1
0
0
0
Change in osmo-cbc[master]: sbcap: Drop unused events
by laforge
Attention is currently required from: pespin. laforge has posted comments on this change. (
https://gerrit.osmocom.org/c/osmo-cbc/+/28801
) Change subject: sbcap: Drop unused events ...................................................................... Patch Set 3: Code-Review+2 -- To view, visit
https://gerrit.osmocom.org/c/osmo-cbc/+/28801
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-cbc Gerrit-Branch: master Gerrit-Change-Id: Ie4843ed5debbd4282df487ada9596b4d75f4b46c Gerrit-Change-Number: 28801 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Tue, 26 Jul 2022 16:43:30 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
2 years, 11 months
1
0
0
0
Change in osmo-cbc[master]: sbcap: Send Error Indication if decoding rx msg fails
by laforge
Attention is currently required from: pespin. laforge has posted comments on this change. (
https://gerrit.osmocom.org/c/osmo-cbc/+/28800
) Change subject: sbcap: Send Error Indication if decoding rx msg fails ...................................................................... Patch Set 3: Code-Review+2 -- To view, visit
https://gerrit.osmocom.org/c/osmo-cbc/+/28800
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-cbc Gerrit-Branch: master Gerrit-Change-Id: I444290f3d697e7485e04eaa38acd8fc3623e0eab Gerrit-Change-Number: 28800 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Tue, 26 Jul 2022 16:43:17 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
2 years, 11 months
1
0
0
0
Change in osmo-cbc[master]: sbcap: Fix typo in sbcap_cause_vals
by laforge
Attention is currently required from: pespin. laforge has posted comments on this change. (
https://gerrit.osmocom.org/c/osmo-cbc/+/28799
) Change subject: sbcap: Fix typo in sbcap_cause_vals ...................................................................... Patch Set 2: Code-Review+2 -- To view, visit
https://gerrit.osmocom.org/c/osmo-cbc/+/28799
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-cbc Gerrit-Branch: master Gerrit-Change-Id: I519a86e5292c39bf1ad502c587838e7b62a0e64f Gerrit-Change-Number: 28799 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Tue, 26 Jul 2022 16:42:57 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
2 years, 11 months
1
0
0
0
← Newer
1
...
34
35
36
37
38
39
40
...
218
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
Results per page:
10
25
50
100
200