The Osmocom RSPRO protocol is a protocol for remote SIM card access, i.e. extending the SIM card interface between phone/mdoem (UE) and a remote SIM card reader. The primary user of this protocol is osmo-remsim software suite, which can be found at https://osmocom.org/projects/osmo-remsim/wiki RSPRO is specified in ASN.1 using BER and runs on top of the IPA multiplex (protocol-gsm_ipa.c). Change-Id: Ibcdb2c92281d05c36e3973de4d7ec4aa0cd9b207laforge/rspro
parent
8683c4e328
commit
3604ad4f2c
@ -0,0 +1,31 @@ |
||||
# CMakeLists.txt |
||||
# |
||||
# Wireshark - Network traffic analyzer |
||||
# By Gerald Combs <gerald@wireshark.org> |
||||
# Copyright 1998 Gerald Combs |
||||
# |
||||
# SPDX-License-Identifier: GPL-2.0-or-later |
||||
# |
||||
|
||||
set( PROTOCOL_NAME rspro ) |
||||
|
||||
set( PROTO_OPT ) |
||||
|
||||
set( ASN_FILE_LIST |
||||
RSPRO.asn |
||||
) |
||||
|
||||
set( EXTRA_DIST |
||||
${ASN_FILE_LIST} |
||||
packet-${PROTOCOL_NAME}-template.c |
||||
${PROTOCOL_NAME}.cnf |
||||
) |
||||
|
||||
set( SRC_FILES |
||||
${EXTRA_DIST} |
||||
${EXT_ASN_FILE_LIST} |
||||
) |
||||
|
||||
set( A2W_FLAGS ) |
||||
|
||||
ASN2WRS() |
@ -0,0 +1,347 @@ |
||||
---------------------------------------------------------------------- |
||||
-- RSPRO - Remote SIM Protocol, part of Osmocom Remote SIM Suite |
||||
-- (C) 2018 by Harald Welte <laforge@gnumonks.org> |
||||
-- All Rights Reserved |
||||
-- |
||||
-- SPDX-License-Identifier: GPL-2.0+ |
||||
-- |
||||
-- This program is free software; you can redistribute it and/or modify |
||||
-- it under the terms of the GNU General Public License as published by |
||||
-- the Free Software Foundation; either version 2 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 General Public License for more details. |
||||
-- |
||||
-- You should have received a copy of the GNU General Public License along |
||||
-- with this program; if not, write to the Free Software Foundation, Inc., |
||||
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||||
-- |
||||
---------------------------------------------------------------------- |
||||
|
||||
RSPRO DEFINITIONS |
||||
|
||||
IMPLICIT TAGS |
||||
|
||||
::= |
||||
|
||||
BEGIN |
||||
|
||||
EXPORTS |
||||
RsproPDU |
||||
; |
||||
|
||||
---------------------------------------------------------------------- |
||||
-- Elementary Data Types |
||||
---------------------------------------------------------------------- |
||||
|
||||
-- Some random ID the requestor can chose and which the client echos back in a response. |
||||
-- This allows multiple outstanding commands in flight and matching of responses to requests. |
||||
OperationTag ::= INTEGER(0..2147483647) |
||||
|
||||
-- Unique identifier of a given SIM bank |
||||
BankId ::= INTEGER(0..1023) |
||||
|
||||
-- Unique identifier of a given client (modem) |
||||
ClientId ::= INTEGER(0..1023) |
||||
|
||||
ComponentType ::= ENUMERATED { |
||||
-- client: Modems / Phones |
||||
remsimClient (0), |
||||
-- server: Coordination |
||||
remsimServer (1), |
||||
-- bank daemon: SIM cards |
||||
remsimBankd (2) |
||||
} |
||||
ComponentName ::= IA5String (SIZE (1..32)) |
||||
ComponentIdentity ::= SEQUENCE { |
||||
type ComponentType, |
||||
name ComponentName, |
||||
software [0] ComponentName, |
||||
swVersion [1] ComponentName, |
||||
hwManufacturer [2] ComponentName OPTIONAL, |
||||
hwModel [3] ComponentName OPTIONAL, |
||||
hwSerialNr [4] ComponentName OPTIONAL, |
||||
hwVersion [5] ComponentName OPTIONAL, |
||||
fwVersion [6] ComponentName OPTIONAL, |
||||
... |
||||
} |
||||
|
||||
-- IP address / port details |
||||
Ipv4Address ::= OCTET STRING (SIZE (4)) |
||||
Ipv6Address ::= OCTET STRING (SIZE (16)) |
||||
IpAddress ::= CHOICE { |
||||
ipv4 [0] Ipv4Address, |
||||
ipv6 [1] Ipv6Address |
||||
} |
||||
PortNumber ::= INTEGER (0..65535) |
||||
IpPort ::= SEQUENCE { |
||||
ip IpAddress, |
||||
port PortNumber |
||||
} |
||||
|
||||
-- Result of a given operation |
||||
ResultCode ::= ENUMERATED { |
||||
ok (0), |
||||
-- client / bank / slot ID not accepted |
||||
illegalClientId (1), |
||||
illegalBankId (2), |
||||
illegalSlotId (3), |
||||
unsupportedProtocolVersion (4), |
||||
unknownSlotmap (5), |
||||
|
||||
-- no card is present in given slot |
||||
cardNotPresent (100), |
||||
-- card is present but unresponsive in given slot |
||||
cardUnresponsive (101), |
||||
-- unrecoverable transmission errors detected |
||||
cardTransmissionError (102), |
||||
... |
||||
} |
||||
|
||||
ErrorCode ::= ENUMERATED { |
||||
-- Bankd or Server has received connection form unknown client (no mapping) |
||||
unknownClientConnected (1), |
||||
-- unexpected disconnect (typically bankd reports client disconnect) |
||||
unexpectedDisconnect (2), |
||||
unexpectedProtocolVersion (3), |
||||
... |
||||
} |
||||
|
||||
ErrorString ::= IA5String (SIZE (1..255)) |
||||
|
||||
ErrorSeverity ::= ENUMERATED { |
||||
minor (1), |
||||
major (2), |
||||
fatal (3), |
||||
... |
||||
} |
||||
|
||||
-- Slot number within a SIM bank or a client. |
||||
SlotNumber ::= INTEGER(0..1023) |
||||
|
||||
-- Slot identity on client (modem) side |
||||
ClientSlot ::= SEQUENCE { |
||||
clientId ClientId, |
||||
slotNr SlotNumber, |
||||
... |
||||
} |
||||
|
||||
-- Slot identity on SIM bank side |
||||
BankSlot ::= SEQUENCE { |
||||
bankId BankId, |
||||
slotNr SlotNumber, |
||||
... |
||||
} |
||||
|
||||
ATR ::= OCTET STRING (SIZE (1..55)) |
||||
|
||||
-- flags related to a TPDU in either of the two directions |
||||
TpduFlags ::= SEQUENCE { |
||||
-- indicates a TPDU header is present in this message |
||||
tpduHeaderPresent BOOLEAN, |
||||
-- indicates last part of transmission in this direction |
||||
finalPart BOOLEAN, |
||||
-- indicates a PB is present and we should continue with TX |
||||
procByteContinueTx BOOLEAN, |
||||
-- indicates a PB is present and we should continue with RX |
||||
procByteContinueRx BOOLEAN, |
||||
... |
||||
} |
||||
|
||||
--- physical state of a given slot |
||||
SlotPhysStatus ::= SEQUENCE { |
||||
-- is RST activated by the modem? |
||||
resetActive [0] BOOLEAN, |
||||
-- is VCC applied by the modem? |
||||
vccPresent [1] BOOLEAN OPTIONAL, |
||||
-- is CLK applied by the modem? |
||||
clkActive [2] BOOLEAN OPTIONAL, -- not all hardware supports this |
||||
-- is card presence signalled to the modem? |
||||
cardPresent [3] BOOLEAN OPTIONAL, |
||||
... |
||||
} |
||||
|
||||
---------------------------------------------------------------------- |
||||
-- Messages |
||||
---------------------------------------------------------------------- |
||||
|
||||
|
||||
-- BANKD->SERVER: SIM Bank connects to central server |
||||
ConnectBankReq ::= SEQUENCE { |
||||
-- identity of the bank that is connecting to the server |
||||
identity ComponentIdentity, |
||||
-- bank number, pre-configured on bank side |
||||
bankId BankId, |
||||
numberOfSlots SlotNumber, |
||||
... |
||||
} |
||||
ConnectBankRes ::= SEQUENCE { |
||||
-- identity of the server to which the bank is connecting |
||||
identity ComponentIdentity, |
||||
result ResultCode, |
||||
... |
||||
} |
||||
|
||||
-- CLIENT->SERVER or CLIENT->BANKD |
||||
ConnectClientReq ::= SEQUENCE { |
||||
-- identity of the client that is connecting to the server/bankd |
||||
identity ComponentIdentity, |
||||
clientSlot ClientSlot OPTIONAL, -- mandatory for CL->BANKD; CL->SERVER: old identity, if any |
||||
... |
||||
} |
||||
ConnectClientRes ::= SEQUENCE { |
||||
-- identity of the bankd/server to which the client is connecting |
||||
identity ComponentIdentity, |
||||
result ResultCode, |
||||
... |
||||
} |
||||
|
||||
-- SERVER->BANKD: create a mapping between a given Bank:Slot <-> Client:Slot |
||||
CreateMappingReq ::= SEQUENCE { |
||||
client ClientSlot, |
||||
bank BankSlot, |
||||
... |
||||
} |
||||
CreateMappingRes ::= SEQUENCE { |
||||
result ResultCode, |
||||
... |
||||
} |
||||
|
||||
-- SERVER->BANKD: remove a mapping between a given Bank:Slot <-> Client:Slot |
||||
RemoveMappingReq ::= SEQUENCE { |
||||
client ClientSlot, |
||||
bank BankSlot, |
||||
... |
||||
} |
||||
RemoveMappingRes ::= SEQUENCE { |
||||
result ResultCode, |
||||
... |
||||
} |
||||
|
||||
-- SERVER->CLIENT: set Client ID |
||||
ConfigClientIdReq ::= SEQUENCE { |
||||
-- server-allocated assignment of a client ID |
||||
clientSlot ClientSlot, |
||||
... |
||||
} |
||||
ConfigClientIdRes ::= SEQUENCE { |
||||
result ResultCode, |
||||
... |
||||
} |
||||
|
||||
-- SERVER->CLIENT: set BankId/Slot and IP/Port |
||||
ConfigClientBankReq ::= SEQUENCE { |
||||
-- server-allocated assignment of a client ID |
||||
bankSlot BankSlot, |
||||
-- bank to which the client shall connect |
||||
bankd IpPort, |
||||
... |
||||
} |
||||
ConfigClientBankRes ::= SEQUENCE { |
||||
result ResultCode, |
||||
... |
||||
} |
||||
|
||||
|
||||
-- BANKD->CLIENT: configure the ATR which the card emulator (client) shall send to the modem |
||||
SetAtrReq ::= SEQUENCE { |
||||
slot ClientSlot, |
||||
atr ATR, |
||||
... |
||||
} |
||||
SetAtrRes ::= SEQUENCE { |
||||
result ResultCode, |
||||
... |
||||
} |
||||
|
||||
-- CLIENT->BANKD: TPDU in Modem -> Card direction |
||||
TpduModemToCard ::= SEQUENCE { |
||||
-- we include fully-qualified bank and client slots for easier debugging |
||||
fromClientSlot ClientSlot, |
||||
toBankSlot BankSlot, |
||||
flags TpduFlags, |
||||
data OCTET STRING, |
||||
... |
||||
} |
||||
|
||||
-- BANKD->CLIENT: TPDU in Card -> Modem direction |
||||
TpduCardToModem ::= SEQUENCE { |
||||
-- we include fully-qualified bank and client slots for easier debugging |
||||
fromBankSlot BankSlot, |
||||
toClientSlot ClientSlot, |
||||
flags TpduFlags, |
||||
data OCTET STRING, |
||||
... |
||||
} |
||||
|
||||
-- CLIENT->BANKD: indciation about the current status of a client (modem side) |
||||
ClientSlotStatusInd ::= SEQUENCE { |
||||
fromClientSlot ClientSlot, |
||||
toBankSlot BankSlot, |
||||
slotPhysStatus SlotPhysStatus, |
||||
... |
||||
} |
||||
|
||||
-- BANKD->CLIENT: indciation about the current status of a bank (modem side) |
||||
BankSlotStatusInd ::= SEQUENCE { |
||||
fromBankSlot BankSlot, |
||||
toClientSlot ClientSlot, |
||||
slotPhysStatus SlotPhysStatus, |
||||
... |
||||
} |
||||
|
||||
-- *->SERVER: indication about some kind of error |
||||
ErrorInd ::= SEQUENCE { |
||||
-- whoever is detecting + sending us the error |
||||
sender ComponentType, |
||||
severity ErrorSeverity, |
||||
code ErrorCode, |
||||
-- any bank-side slot that's affected |
||||
bankSlot [0] BankSlot OPTIONAL, |
||||
-- any client-side slot that's affected |
||||
clientSlot [1] ClientSlot OPTIONAL, |
||||
-- any additional textual information |
||||
errorString [2] ErrorString OPTIONAL, |
||||
... |
||||
} |
||||
|
||||
|
||||
---------------------------------------------------------------------- |
||||
-- PDU |
||||
---------------------------------------------------------------------- |
||||
|
||||
RsproPDUchoice ::= CHOICE { |
||||
-- configuration + management |
||||
connectBankReq [0] ConnectBankReq, |
||||
connectBankRes [1] ConnectBankRes, |
||||
connectClientReq [2] ConnectClientReq, |
||||
connectClientRes [3] ConnectClientRes, |
||||
createMappingReq [4] CreateMappingReq, |
||||
createMappingRes [5] CreateMappingRes, |
||||
removeMappingReq [6] RemoveMappingReq, |
||||
removeMappingRes [7] RemoveMappingRes, |
||||
configClientIdReq [8] ConfigClientIdReq, |
||||
configClientIdRes [9] ConfigClientIdRes, |
||||
configClientBankReq [17] ConfigClientBankReq, |
||||
configClientBankRes [18] ConfigClientBankRes, |
||||
errorInd [16] ErrorInd, |
||||
-- APDUs etc. |
||||
setAtrReq [10] SetAtrReq, |
||||
setAtrRes [11] SetAtrRes, |
||||
tpduModemToCard [12] TpduModemToCard, |
||||
tpduCardToModem [13] TpduCardToModem, |
||||
clientSlotStatusInd [14] ClientSlotStatusInd, |
||||
bankSlotStatusInd [15] BankSlotStatusInd, |
||||
... |
||||
} |
||||
|
||||
RsproPDU ::= SEQUENCE { |
||||
version [0] INTEGER(0..32), |
||||
tag [1] OperationTag, |
||||
msg [2] RsproPDUchoice |
||||
} |
||||
|
||||
END |
@ -0,0 +1,95 @@ |
||||
/* packet-rspro.c
|
||||
* Routines for RSPRO (Remote SIM Protocol) packet dissection |
||||
* (C) 2019 by Harald Welte <laforge@gnumonks.org> |
||||
* |
||||
* Wireshark - Network traffic analyzer |
||||
* By Gerald Combs <gerald@wireshark.org> |
||||
* Copyright 1998 Gerald Combs |
||||
* |
||||
* SPDX-License-Identifier: GPL-2.0-or-later |
||||
*/ |
||||
|
||||
#ifdef HAVE_CONFIG_H |
||||
# include "config.h" |
||||
#endif |
||||
|
||||
#include <glib.h> |
||||
#include <epan/packet.h> |
||||
#include <epan/conversation.h> |
||||
|
||||
#include <stdio.h> |
||||
#include <string.h> |
||||
|
||||
#include "packet-ber.h" |
||||
#include "packet-rspro.h" |
||||
|
||||
#define PNAME "Remote SIM Protocol" |
||||
#define PSNAME "RSPRO" |
||||
#define PFNAME "rspro" |
||||
#define IPAC_PROTO_EXT_RSPRO 0x07 |
||||
static dissector_handle_t rspro_handle=NULL; |
||||
|
||||
void proto_reg_handoff_rspro(void); |
||||
void proto_register_rspro(void); |
||||
|
||||
/* Initialize the protocol and registered fields */ |
||||
static int proto_rspro = -1; |
||||
|
||||
#include "packet-rspro-hf.c" |
||||
|
||||
/* Initialize the subtree pointers */ |
||||
static int ett_rspro = -1; |
||||
|
||||
#include "packet-rspro-ett.c" |
||||
|
||||
#include "packet-rspro-fn.c" |
||||
|
||||
|
||||
static int |
||||
dissect_rspro(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) |
||||
{ |
||||
proto_item *rspro_item = NULL; |
||||
proto_tree *rspro_tree = NULL; |
||||
|
||||
/* make entry in the Protocol column on summary display */ |
||||
col_set_str(pinfo->cinfo, COL_PROTOCOL, PNAME); |
||||
|
||||
/* create the rspro protocol tree */ |
||||
if (tree) { |
||||
rspro_item = proto_tree_add_item(tree, proto_rspro, tvb, 0, -1, FALSE); |
||||
rspro_tree = proto_item_add_subtree(rspro_item, ett_rspro); |
||||
|
||||
dissect_RsproPDU_PDU(tvb, pinfo, rspro_tree, data); |
||||
} |
||||
|
||||
return tvb_captured_length(tvb); |
||||
} |
||||
|
||||
/*--- proto_register_rspro -------------------------------------------*/ |
||||
void proto_register_rspro(void) { |
||||
/* List of fields */ |
||||
static hf_register_info hf[] = { |
||||
#include "packet-rspro-hfarr.c" |
||||
}; |
||||
|
||||
/* List of subtrees */ |
||||
static gint *ett[] = { |
||||
&ett_rspro, |
||||
#include "packet-rspro-ettarr.c" |
||||
}; |
||||
|
||||
/* Register protocol */ |
||||
proto_rspro = proto_register_protocol(PNAME, PSNAME, PFNAME); |
||||
/* Register fields and subtrees */ |
||||
proto_register_field_array(proto_rspro, hf, array_length(hf)); |
||||
proto_register_subtree_array(ett, array_length(ett)); |
||||
} |
||||
|
||||
|
||||
/*--- proto_reg_handoff_rspro ---------------------------------------*/ |
||||
void |
||||
proto_reg_handoff_rspro(void) |
||||
{ |
||||
rspro_handle = create_dissector_handle(dissect_rspro, proto_rspro); |
||||
dissector_add_uint_with_preference("ipa.osmo.protocol", IPAC_PROTO_EXT_RSPRO, rspro_handle); |
||||
} |
@ -0,0 +1,16 @@ |
||||
/* packet-rspro.h
|
||||
* Routines for RSPRO (remote SIM protocol) packet dissection |
||||
* (C) 2019 by Harald Welte <laforge@gnumonks.org> |
||||
* |
||||
* Wireshark - Network traffic analyzer |
||||
* By Gerald Combs <gerald@wireshark.org> |
||||
* Copyright 1998 Gerald Combs |
||||
* |
||||
* SPDX-License-Identifier: GPL-2.0-or-later |
||||
*/ |
||||
|
||||
#ifndef PACKET_RSPRO_H |
||||
#define PACKET_RSPRO_H |
||||
|
||||
|
||||
#endif /* PACKET_RSPRO_H */ |
@ -0,0 +1,28 @@ |
||||
# rspro.cnf |
||||
# rspro conformation file |
||||
# Copyright 2019 Harald Welte |
||||
|
||||
#.OPT |
||||
BER |
||||
#.END |
||||
|
||||
#.MODULE_IMPORT |
||||
|
||||
#.EXPORTS |
||||
|
||||
#.PDU |
||||
RsproPDU |
||||
|
||||
#.NO_EMIT |
||||
|
||||
#.TYPE_RENAME |
||||
|
||||
#.FIELD_RENAME |
||||
|
||||
#.FN_HDR RsproPDUchoice |
||||
gint choice_index; |
||||
#.FN_BODY RsproPDUchoice VAL_PTR = &choice_index |
||||
%(DEFAULT_BODY)s |
||||
col_append_str(actx->pinfo->cinfo, COL_INFO, val_to_str(choice_index, rspro_RsproPDUchoice_vals, "Unknown (%%u)")); |
||||
|
||||
#.END |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,24 @@ |
||||
/* Do not modify this file. Changes will be overwritten. */ |
||||
/* Generated automatically by the ASN.1 to Wireshark dissector compiler */ |
||||
/* packet-rspro.h */ |
||||
/* asn2wrs.py -p rspro -c ./rspro.cnf -s ./packet-rspro-template -D . -O ../.. RSPRO.asn */ |
||||
|
||||
/* Input file: packet-rspro-template.h */ |
||||
|
||||
#line 1 "./asn1/rspro/packet-rspro-template.h" |
||||
/* packet-rspro.h
|
||||
* Routines for RSPRO (remote SIM protocol) packet dissection |
||||
* (C) 2019 by Harald Welte <laforge@gnumonks.org> |
||||
* |
||||
* Wireshark - Network traffic analyzer |
||||
* By Gerald Combs <gerald@wireshark.org> |
||||
* Copyright 1998 Gerald Combs |
||||
* |
||||
* SPDX-License-Identifier: GPL-2.0-or-later |
||||
*/ |
||||
|
||||
#ifndef PACKET_RSPRO_H |
||||
#define PACKET_RSPRO_H |
||||
|
||||
|
||||
#endif /* PACKET_RSPRO_H */ |
Loading…
Reference in new issue