pespin has uploaded this change for review. ( 
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, 59 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-cbc refs/changes/00/28800/1

diff --git a/include/osmocom/cbc/sbcap_msg.h b/include/osmocom/cbc/sbcap_msg.h
index 1f2c350..882e0b9 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);
diff --git a/include/osmocom/sbcap/sbcap_common.h 
b/include/osmocom/sbcap/sbcap_common.h
index 795bf25..167e5d1 100644
--- a/include/osmocom/sbcap/sbcap_common.h
+++ b/include/osmocom/sbcap/sbcap_common.h
@@ -146,3 +146,6 @@

 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..cd22fee 100644
--- a/src/sbcap/sbcap_common.c
+++ b/src/sbcap/sbcap_common.c
@@ -135,3 +135,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..ce59397 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);
+               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 735cf8b..55ca0e2 100644
--- a/src/sbcap_msg.c
+++ b/src/sbcap_msg.c
@@ -291,3 +291,39 @@

        return pdu;
 }
+
+/* generate a SBc-AP ERROR INDICATION, 3GPP TS 29.168 4.3.4.2A.1 */
+SBcAP_SBC_AP_PDU_t *sbcap_gen_error_ind(void *ctx, SBcAP_Cause_t cause)
+{
+       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 0
+       /* 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_Criticality_Diagnostics);
+       ie->value.choice.Criticality_Diagnostics = ...;
+       ASN_SEQUENCE_ADD(as_pdu, ie);
+#endif
+       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: 1
Gerrit-Owner: pespin <[email protected]>
Gerrit-MessageType: newchange

Reply via email to