Change in osmocom-bb[master]: layer23/sap_interface.c: define missing enums and use them

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Jan 7 15:39:53 UTC 2019


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/12439 )

Change subject: layer23/sap_interface.c: define missing enums and use them
......................................................................

layer23/sap_interface.c: define missing enums and use them

Change-Id: I4ba5a8a42bf25d04b152ac3f1f0e4d7eac7f068f
---
M src/host/layer23/include/osmocom/bb/common/sap_interface.h
M src/host/layer23/src/common/sap_interface.c
2 files changed, 55 insertions(+), 24 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/host/layer23/include/osmocom/bb/common/sap_interface.h b/src/host/layer23/include/osmocom/bb/common/sap_interface.h
index b8a3420..270c565 100644
--- a/src/host/layer23/include/osmocom/bb/common/sap_interface.h
+++ b/src/host/layer23/include/osmocom/bb/common/sap_interface.h
@@ -57,6 +57,37 @@
 	SAP_TRANSPORT_PROTOCOL = 0x09
 };
 
+/* Table 5.18: Possible values for ResultCode */
+enum sap_result_type {
+	SAP_RESULT_OK_REQ_PROC_CORR = 0x00,
+	SAP_RESULT_ERROR_NO_REASON = 0x01,
+	SAP_RESULT_ERROR_CARD_NOT_ACC = 0x02,
+	SAP_RESULT_ERROR_CARD_POWERED_OFF = 0x03,
+	SAP_RESULT_ERROR_CARD_REMOVED = 0x04,
+	SAP_RESULT_ERROR_CARD_POWERED_ON = 0x05,
+	SAP_RESULT_ERROR_DATA_UNAVAIL = 0x06,
+	SAP_RESULT_ERROR_NOT_SUPPORTED = 0x07,
+};
+
+/* Table 5.19: Possible values for StatusChange */
+enum sap_card_status_type {
+	SAP_CARD_STATUS_UNKNOWN_ERROR = 0x00,
+	SAP_CARD_STATUS_RESET = 0x01,
+	SAP_CARD_STATUS_NOT_ACC = 0x02,
+	SAP_CARD_STATUS_REMOVED = 0x03,
+	SAP_CARD_STATUS_INSERTED = 0x04,
+	SAP_CARD_STATUS_RECOVERED = 0x05,
+};
+
+/* Table 5.16: Possible values for ConnectionStatus */
+enum sap_conn_status_type {
+	SAP_CONN_STATUS_OK_READY = 0x00,
+	SAP_CONN_STATUS_ERROR_CONN = 0x01,
+	SAP_CONN_STATUS_ERROR_MAX_MSG_SIZE = 0x02,
+	SAP_CONN_STATUS_ERROR_SMALL_MSG_SIZE = 0x03,
+	SAP_CONN_STATUS_OK_CALL = 0x04,
+};
+
 struct sap_param {
 	uint8_t id;
 	uint16_t len;
diff --git a/src/host/layer23/src/common/sap_interface.c b/src/host/layer23/src/common/sap_interface.c
index 3faa949..ab683f9 100644
--- a/src/host/layer23/src/common/sap_interface.c
+++ b/src/host/layer23/src/common/sap_interface.c
@@ -91,35 +91,35 @@
 
 /* Table 5.18: Possible values for ResultCode */
 static const struct value_string sap_result_names[] = {
-	{ 0, "OK, request processed correctly" },
-	{ 1, "Error, no reason defined" },
-	{ 2, "Error, card not accessible" },
-	{ 3, "Error, card (already) powered off" },
-	{ 4, "Error, card removed" },
-	{ 5, "Error, card already powered on" },
-	{ 6, "Error, data not available" },
-	{ 7, "Error, not supported "},
+	{ SAP_RESULT_OK_REQ_PROC_CORR,		"OK, request processed correctly" },
+	{ SAP_RESULT_ERROR_NO_REASON,		"Error, no reason defined" },
+	{ SAP_RESULT_ERROR_CARD_NOT_ACC,	"Error, card not accessible" },
+	{ SAP_RESULT_ERROR_CARD_POWERED_OFF,	"Error, card (already) powered off" },
+	{ SAP_RESULT_ERROR_CARD_REMOVED,	"Error, card removed" },
+	{ SAP_RESULT_ERROR_CARD_POWERED_ON,	"Error, card already powered on" },
+	{ SAP_RESULT_ERROR_DATA_UNAVAIL,	"Error, data not available" },
+	{ SAP_RESULT_ERROR_NOT_SUPPORTED,	"Error, not supported "},
 	{ 0, NULL }
 };
 
 /* Table 5.19: Possible values for StatusChange */
-static const struct value_string sap_status_change_names[] = {
-	{ 0, "Unknown Error" },
-	{ 1, "Card reset" },
-	{ 2, "Card not accessible" },
-	{ 3, "Card removed" },
-	{ 4, "Card inserted" },
-	{ 5, "Card recovered" },
+static const struct value_string sap_card_status_names[] = {
+	{ SAP_CARD_STATUS_UNKNOWN_ERROR,	"Unknown Error" },
+	{ SAP_CARD_STATUS_RESET,		"Card reset" },
+	{ SAP_CARD_STATUS_NOT_ACC,		"Card not accessible" },
+	{ SAP_CARD_STATUS_REMOVED,		"Card removed" },
+	{ SAP_CARD_STATUS_INSERTED,		"Card inserted" },
+	{ SAP_CARD_STATUS_RECOVERED,		"Card recovered" },
 	{ 0, NULL }
 };
 
 /* Table 5.16: Possible values for ConnectionStatus */
-static const struct value_string sap_status_names[] = {
-	{ 0, "OK, Server can fulfill requirements" },
-	{ 1, "Error, Server unable to establish connection" },
-	{ 2, "Error, Server does not support maximum message size" },
-	{ 3, "Error, maximum message size by Client is too small" },
-	{ 4, "OK, ongoing call" },
+static const struct value_string sap_conn_status_names[] = {
+	{ SAP_CONN_STATUS_OK_READY,		"OK, Server can fulfill requirements" },
+	{ SAP_CONN_STATUS_ERROR_CONN,		"Error, Server unable to establish connection" },
+	{ SAP_CONN_STATUS_ERROR_MAX_MSG_SIZE,	"Error, Server does not support maximum message size" },
+	{ SAP_CONN_STATUS_ERROR_SMALL_MSG_SIZE,	"Error, maximum message size by Client is too small" },
+	{ SAP_CONN_STATUS_OK_CALL,		"OK, ongoing call" },
 	{ 0, NULL }
 };
 
@@ -319,7 +319,7 @@
 
 	switch(msg->id){
 	case SAP_CONNECT_RESP:
-		LOGP(DSAP, LOGL_INFO, "Status: %s\n", get_value_string(sap_status_names, msg->params[0].value[0]));
+		LOGP(DSAP, LOGL_INFO, "Status: %s\n", get_value_string(sap_conn_status_names, msg->params[0].value[0]));
 		if(msg->params[0].value[0] == 0){
 			ms->sap_entity.sap_state = SAP_IDLE;
 		}
@@ -335,9 +335,9 @@
 		ms->sap_entity.sap_state = SAP_NOT_CONNECTED;
 		break;
 	case SAP_STATUS_IND:
-		LOGP(DSAP, LOGL_INFO, "New card state: %s\n", get_value_string(sap_status_change_names,
+		LOGP(DSAP, LOGL_INFO, "New card state: %s\n", get_value_string(sap_card_status_names,
 					msg->params[0].value[0]));
-		if(msg->params[0].value[0] != 1){
+		if(msg->params[0].value[0] != SAP_CARD_STATUS_RESET){
 			/* TODO: handle case in which the card is not ready yet */
 		}
 		break;

-- 
To view, visit https://gerrit.osmocom.org/12439
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I4ba5a8a42bf25d04b152ac3f1f0e4d7eac7f068f
Gerrit-Change-Number: 12439
Gerrit-PatchSet: 5
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190107/19683751/attachment.htm>


More information about the gerrit-log mailing list