Reputation: 1054
I'm working on a Javacard applet, and currently I'm looking into creating a connection from my phone to my sim card. I want to send some data to a specific app on my phone, on demand.
On the smartcard, I open the BIP/TCP server channel on port 12345
as follows:
import static uicc.toolkit.ToolkitConstants.*;
import uicc.toolkit.*;
import javacard.framework.*;
public class NetworkApplet extends Applet implements ToolkitInterface {
static final short TCP_TX_BUFFER = Byte.MAX_VALUE * 2;
static final short PORT_SERVER = 12345;
static final byte IDX_ID_SERVER_CHANNEL = 0;
byte[] ids;
@SuppressWarnings("unused")
public static void install(byte[] bArray, short bOffset, byte bLength) throws SystemException {
NetworkApplet applet = new NetworkApplet(bArray, bOffset, bLength);
applet.register();
applet.setupToolkitRegistry();
}
NetworkApplet(byte[] bArray, short bOffset, byte bLength) {
ids = JCSystem.makeTransientByteArray((short) 2, JCSystem.CLEAR_ON_RESET);
}
void setupToolkitRegistry() {
ToolkitRegistry registry = ToolkitRegistrySystem.getEntry();
// snip
registry.setEvent(EVENT_PROFILE_DOWNLOAD);
}
@Override
public void process(APDU apdu) throws ISOException {
// Unused
}
@Override
public void processToolkit(short event) throws ToolkitException {
switch (event) {
case EVENT_PROFILE_DOWNLOAD:
ids[IDX_ID_SERVER_CHANNEL] = openServerChannel(PORT_SERVER, TCP_TX_BUFFER);
break;
// snip
}
}
private static byte openServerChannel(short port, short txCapacity) {
ProactiveHandler handler = ProactiveHandlerSystem.getTheHandler();
ProactiveResponseHandler responseHandler = ProactiveResponseHandlerSystem.getTheHandler();
handler.init(PRO_CMD_OPEN_CHANNEL, (byte) 0, DEV_ID_TERMINAL);
handler.appendTLV(TAG_BUFFER_SIZE, txCapacity);
handler.appendTLV(TAG_UICC_TERMINAL_TRANSPORT_LEVEL, QUAL_TCP_SERVER, port);
if (handler.send() == RES_CMD_PERF) {
return responseHandler.getChannelIdentifier();
} else {
return 0;
}
}
}
Now I have a tcp client running on my Android (it also has to work on iPhone). I've tried connecting it to port 12345
on: 127.0.0.1
, 192.169.0.1
, 192.169.0.2
and localuicc
, but none of those addresses seem to have that port open. I get that my card is on a different subnet than my phone itself, but how do I reach it?
TS 102485 seems to suggest that the terminal (in that spec equivalent to the phone) should be able to resolve localuicc
just like localhost
, but when I just ping I get the following:
ping localuicc
ping: unknown host localuicc
I tried looking into the routing tables from my phone, but I don't think it helps very much:
$ cat /proc/net/route
Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
rmnet_data1 E0002D0A 00000000 0001 0 0 0 F8FFFFFF 0 0 0
wlan0 00B2A8C0 00000000 0001 0 0 0 00FFFFFF 0 0 0
Upvotes: 1
Views: 89