diff options
author | Harald Welte <laforge@gnumonks.org> | 2012-09-10 10:49:59 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2014-10-26 19:09:22 +0100 |
commit | ad41863b8d3f3ac7df0c34b2c7d342b864d944cc (patch) | |
tree | d8c28dce9b084dccc01b942e3fa3a69e927a7dbb /src/sim/core.c | |
parent | a0ba4d943816a10e78984d8bbca56fbdbdfe82bb (diff) |
sim: add copyright notices and merge file_codec.c into core.c
Diffstat (limited to 'src/sim/core.c')
-rw-r--r-- | src/sim/core.c | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/src/sim/core.c b/src/sim/core.c index 40a49cf2..bc0d05c8 100644 --- a/src/sim/core.c +++ b/src/sim/core.c @@ -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 <stdint.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); +} + static struct osim_decoded_element * __element_alloc(void *ctx, const char *name, enum osim_element_type type, 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; } - - - - |