<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16981" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2><SPAN 
class=663425811-17082010>hi,</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=663425811-17082010></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=663425811-17082010>i like to write the 
sim client protocol. i do not mean the code of the "sim reader" which 
is part of layer1 inside the phone. before i start, i would like to know 
what you think about my api idea. the api is not the low-level api between 
layer1 and the mobile application (APDU layer). it describes a higher layer 
for application or protocol processes which need to request IMSI, do 
key generation, or store location area information.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=663425811-17082010></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=663425811-17082010>one important thing 
is that different processes must be able request "read", "write", or 
other operations like key generation simultaniously. in order to handle multiple 
requests after each other, a queue inside sim client must exist. afterwar 
processing each request, the result must be sent only to the requesting 
process (if it still exists). <SPAN class=663425811-17082010>a state 
machine watches over the current DF (current selected file area of the sim) and 
changes current "DF" if required, before processing read or write job. also it 
triggers the next job in the queue, if finished with the current 
one.</SPAN></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=663425811-17082010></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=663425811-17082010><STRONG>int handle = 
sim_open(void (*cb)(...))</STRONG></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=663425811-17082010></SPAN></FONT><FONT 
face=Arial size=2><SPAN class=663425811-17082010></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=663425811-17082010>will add a new user 
instance. cb is the function to be called for response, handle is a unique id of 
the process (not a memory pointer, unique at all times after starting 
phone).</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=663425811-17082010></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=663425811-17082010><STRONG>void 
sim_job(struct msgb *msg)</STRONG></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=663425811-17082010><STRONG></STRONG></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=663425811-17082010><STRONG>struct 
sim_job_hdr {</STRONG></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=663425811-17082010><STRONG>    int 
handle;</STRONG></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=663425811-17082010><STRONG>    uint8_t 
job_type;</STRONG></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=663425811-17082010><STRONG>    uint16_t 
file;</STRONG></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=663425811-17082010><STRONG>};</STRONG></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=663425811-17082010></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=663425811-17082010>will add a new job. 
the type defines the job type. examples are "READ" "WRITE" or "GSMKEY" requests. 
the handle is used to assign the read/write job to an instance. the file is used 
to select the correct data file of the sim. the data and len represent the data 
to be written.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=663425811-17082010></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=663425811-17082010><STRONG>void 
cb(struct msgb *msg)</STRONG></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=663425811-17082010></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=663425811-17082010>is called back by 
the sim client when job is done. the handle is given, so multiple user  
instances may use the same callback.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=663425811-17082010></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=663425811-17082010><STRONG>void 
sim_close(int handle)</STRONG></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=663425811-17082010></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=663425811-17082010>will remove user 
instance. outstanding jobs will finish, but no result is given, 
because cb is now unregistered.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=663425811-17082010></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=663425811-17082010></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=663425811-17082010>the coding and 
decoding of SIM files must be done by the application or protocol layer that use 
the sim client.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=663425811-17082010></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=663425811-17082010></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=663425811-17082010>andreas</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=663425811-17082010></SPAN></FONT> </DIV></BODY></HTML>