hi,
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.
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). 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.
int handle =
sim_open(void (*cb)(...))
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).
void
sim_job(struct msgb *msg)
struct
sim_job_hdr {
int
handle;
uint8_t
job_type;
uint16_t
file;
};
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.
void
cb(struct msgb *msg)
is called back by
the sim client when job is done. the handle is given, so multiple user
instances may use the same callback.
void
sim_close(int handle)
will remove user
instance. outstanding jobs will finish, but no result is given,
because cb is now unregistered.
the coding and
decoding of SIM files must be done by the application or protocol layer that use
the sim client.
andreas