mirror of https://gerrit.osmocom.org/libosmocore
sim: add copyright notices and merge file_codec.c into core.c
This commit is contained in:
parent
a0ba4d9438
commit
ad41863b8d
|
@ -9,7 +9,7 @@ noinst_HEADERS = sim_int.h gsm_int.h
|
||||||
|
|
||||||
lib_LTLIBRARIES = libosmosim.la
|
lib_LTLIBRARIES = libosmosim.la
|
||||||
|
|
||||||
libosmosim_la_SOURCES = core.c card_fs_sim.c card_fs_usim.c card_fs_uicc.c file_codec.c reader.c reader_pcsc.c
|
libosmosim_la_SOURCES = core.c card_fs_sim.c card_fs_usim.c card_fs_uicc.c reader.c reader_pcsc.c
|
||||||
# FIXME: use autoconf to determine pcsc include path / library name
|
# FIXME: use autoconf to determine pcsc include path / library name
|
||||||
libosmosim_la_LDFLAGS = -version-info $(LIBVERSION) -lpcsclite
|
libosmosim_la_LDFLAGS = -version-info $(LIBVERSION) -lpcsclite
|
||||||
libosmosim_la_CFLAGS = -I/usr/include/PCSC
|
libosmosim_la_CFLAGS = -I/usr/include/PCSC
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
|
/* classic SIM card specific structures/routines */
|
||||||
|
/*
|
||||||
|
* (C) 2012 by Harald Welte <laforge@gnumonks.org>
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
|
@ -1,3 +1,26 @@
|
||||||
|
/* ETSI UICC specific structures / routines */
|
||||||
|
/*
|
||||||
|
* (C) 2012 by Harald Welte <laforge@gnumonks.org>
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <osmocom/sim/sim.h>
|
#include <osmocom/sim/sim.h>
|
||||||
#include <osmocom/gsm/tlv.h>
|
#include <osmocom/gsm/tlv.h>
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,25 @@
|
||||||
|
/* 3GPP USIM specific structures / routines */
|
||||||
|
/*
|
||||||
|
* (C) 2012 by Harald Welte <laforge@gnumonks.org>
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
|
@ -1,9 +1,59 @@
|
||||||
|
/* Core routines for SIM/UICC/USIM access */
|
||||||
|
/*
|
||||||
|
* (C) 2012 by Harald Welte <laforge@gnumonks.org>
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <osmocom/core/talloc.h>
|
#include <osmocom/core/talloc.h>
|
||||||
#include <osmocom/sim/sim.h>
|
#include <osmocom/sim/sim.h>
|
||||||
|
|
||||||
|
struct osim_decoded_data *osim_file_decode(struct osim_file *file,
|
||||||
|
int len, uint8_t *data)
|
||||||
|
{
|
||||||
|
struct osim_decoded_data *dd;
|
||||||
|
|
||||||
|
if (!file->desc->ops.parse)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
dd = talloc_zero(file, struct osim_decoded_data);
|
||||||
|
dd->file = file;
|
||||||
|
|
||||||
|
if (file->desc->ops.parse(dd, file->desc, len, data) < 0) {
|
||||||
|
talloc_free(dd);
|
||||||
|
return NULL;
|
||||||
|
} else
|
||||||
|
return dd;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct msgb *osim_file_encode(const struct osim_file_desc *desc,
|
||||||
|
const struct osim_decoded_data *data)
|
||||||
|
{
|
||||||
|
if (!desc->ops.encode)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return desc->ops.encode(desc, data);
|
||||||
|
}
|
||||||
|
|
||||||
static struct osim_decoded_element *
|
static struct osim_decoded_element *
|
||||||
__element_alloc(void *ctx, const char *name, enum osim_element_type type,
|
__element_alloc(void *ctx, const char *name, enum osim_element_type type,
|
||||||
enum osim_element_repr repr)
|
enum osim_element_repr repr)
|
||||||
|
@ -166,7 +216,3 @@ struct msgb *osim_new_apdumsg(uint8_t cla, uint8_t ins, uint8_t p1,
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include <osmocom/core/talloc.h>
|
|
||||||
#include <osmocom/sim/sim.h>
|
|
||||||
|
|
||||||
struct osim_decoded_data *osim_file_decode(struct osim_file *file,
|
|
||||||
int len, uint8_t *data)
|
|
||||||
{
|
|
||||||
struct osim_decoded_data *dd;
|
|
||||||
|
|
||||||
if (!file->desc->ops.parse)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
dd = talloc_zero(file, struct osim_decoded_data);
|
|
||||||
dd->file = file;
|
|
||||||
|
|
||||||
if (file->desc->ops.parse(dd, file->desc, len, data) < 0) {
|
|
||||||
talloc_free(dd);
|
|
||||||
return NULL;
|
|
||||||
} else
|
|
||||||
return dd;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct msgb *osim_file_encode(const struct osim_file_desc *desc,
|
|
||||||
const struct osim_decoded_data *data)
|
|
||||||
{
|
|
||||||
if (!desc->ops.encode)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return desc->ops.encode(desc, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,26 @@
|
||||||
|
/* Card reader abstraction for libosmosim */
|
||||||
|
/*
|
||||||
|
* (C) 2012 by Harald Welte <laforge@gnumonks.org>
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
@ -1,3 +1,26 @@
|
||||||
|
/* PC/SC Card reader backend for libosmosim */
|
||||||
|
/*
|
||||||
|
* (C) 2012 by Harald Welte <laforge@gnumonks.org>
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -1,3 +1,23 @@
|
||||||
|
/* libosmosim test application - currently simply dumps a USIM */
|
||||||
|
/* (C) 2012 by Harald Welte <laforge@gnumonks.org>
|
||||||
|
* All Rights Reserved
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -9,10 +29,7 @@
|
||||||
#include <osmocom/gsm/tlv.h>
|
#include <osmocom/gsm/tlv.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* FIXME: this needs to be moved to card_fs_uicc.c */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* 11.1.1 */
|
/* 11.1.1 */
|
||||||
static struct msgb *_select_file(struct osim_chan_hdl *st, uint8_t p1, uint8_t p2,
|
static struct msgb *_select_file(struct osim_chan_hdl *st, uint8_t p1, uint8_t p2,
|
||||||
|
@ -126,6 +143,8 @@ static struct msgb *update_binary(struct osim_chan_hdl *st, uint16_t offset,
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int dump_fcp_template(struct tlv_parsed *tp)
|
static int dump_fcp_template(struct tlv_parsed *tp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -379,7 +398,6 @@ int main(int argc, char **argv)
|
||||||
dump_fcp_template_msg(msg);
|
dump_fcp_template_msg(msg);
|
||||||
msgb_free(msg);
|
msgb_free(msg);
|
||||||
|
|
||||||
#if 1
|
|
||||||
{
|
{
|
||||||
struct osim_file_desc *ofd;
|
struct osim_file_desc *ofd;
|
||||||
llist_for_each_entry(ofd, &chan->cwd->child_list, list) {
|
llist_for_each_entry(ofd, &chan->cwd->child_list, list) {
|
||||||
|
@ -393,7 +411,6 @@ int main(int argc, char **argv)
|
||||||
dump_file(chan, ofd->fid);
|
dump_file(chan, ofd->fid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue