summaryrefslogtreecommitdiffstats
path: root/src/host/layer23/src/common/sap_interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/host/layer23/src/common/sap_interface.c')
-rw-r--r--src/host/layer23/src/common/sap_interface.c81
1 files changed, 5 insertions, 76 deletions
diff --git a/src/host/layer23/src/common/sap_interface.c b/src/host/layer23/src/common/sap_interface.c
index e3be3fb6..7b8717d3 100644
--- a/src/host/layer23/src/common/sap_interface.c
+++ b/src/host/layer23/src/common/sap_interface.c
@@ -26,6 +26,7 @@
#include <osmocom/bb/common/osmocom_data.h>
#include <osmocom/bb/common/logging.h>
#include <osmocom/bb/common/sap_interface.h>
+#include <osmocom/bb/common/sap_proto.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/talloc.h>
@@ -47,82 +48,6 @@
static void sap_connect(struct osmocom_ms *ms);
-/* Table 5.15: List of Parameter IDs */
-static const struct value_string sap_param_names[] = {
- { SAP_MAX_MSG_SIZE, "MaxMsgSize" },
- { SAP_CONNECTION_STATUS, "ConnectionStatus" },
- { SAP_RESULT_CODE, "ResultCode" },
- { SAP_DISCONNECTION_TYPE, "DisconnectionType" },
- { SAP_COMMAND_APDU, "CommandAPDU" },
- { SAP_COMMAND_APDU_7816, "CommandAPDU7816" },
- { SAP_RESPONSE_APDU, "ResponseAPDU" },
- { SAP_ATR, "ATR" },
- { SAP_CARD_READER_STATUS, "CardReaderStatus" },
- { SAP_STATUS_CHANGE, "StatusChange" },
- { SAP_TRANSPORT_PROTOCOL, "TransportProtocol" },
- { 0, NULL }
-};
-
-/* Table 5.1: Message Overview */
-static const struct value_string sap_msg_names[] = {
- { SAP_CONNECT_REQ, "CONNECT_REQ" },
- { SAP_CONNECT_RESP, "CONNECT_RESP" },
- { SAP_DISCONNECT_REQ, "DISCONNECT_REQ" },
- { SAP_DISCONNECT_RESP, "DISCONNECT_RESP" },
- { SAP_DISCONNECT_IND, "DISCONNECT_IND" },
- { SAP_TRANSFER_APDU_REQ, "TRANSFER_APDU_REQ" },
- { SAP_TRANSFER_APDU_RESP, "TRANSFER_APDU_RESP" },
- { SAP_TRANSFER_ATR_REQ, "TRANSFER_ATR_REQ" },
- { SAP_TRANSFER_ATR_RESP, "TRANSFER_ATR_RESP" },
- { SAP_POWER_SIM_OFF_REQ, "POWER_SIM_OFF_REQ" },
- { SAP_POWER_SIM_OFF_RESP, "POWER_SIM_OFF_RESP" },
- { SAP_POWER_SIM_ON_REQ, "POWER_SIM_ON_REQ" },
- { SAP_POWER_SIM_ON_RESP, "POWER_SIM_ON_RESP" },
- { SAP_RESET_SIM_REQ, "RESET_SIM_REQ" },
- { SAP_RESET_SIM_RESP, "RESET_SIM_RESP" },
- { SAP_TRANSFER_CARD_READER_STATUS_REQ, "TRANSFER_CARD_READER_STATUS_REQ" },
- { SAP_TRANSFER_CARD_READER_STATUS_RESP, "TRANSFER_CARD_READER_STATUS_RESP" },
- { SAP_STATUS_IND, "STATUS_IND" },
- { SAP_ERROR_RESP, "ERROR_RESP" },
- { SAP_SET_TRANSPORT_PROTOCOL_REQ, "SET_TRANSPORT_PROTOCOL_REQ" },
- { SAP_SET_TRANSPORT_PROTOCOL_RESP, "SET_TRANSPORT_PROTOCOL_RESP" },
- { 0, NULL }
-};
-
-/* Table 5.18: Possible values for ResultCode */
-static const struct value_string sap_result_names[] = {
- { 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_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_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 }
-};
-
static struct msgb *sap_create_msg(uint8_t id, uint8_t num_params, struct sap_param *params)
{
struct msgb *msg;
@@ -186,9 +111,13 @@ static int sap_parse_result(struct sap_param *param)
get_value_string(sap_result_names, param->value[0]));
}
+#if 0
+ /* FIXME: ARRAY_SIZE() is not applicable to
+ * extern const struct value_string[] */
if(param->value[0] > ARRAY_SIZE(sap_result_names)){
return -1;
}
+#endif
return 0;
}