aboutsummaryrefslogtreecommitdiffstats
path: root/src/sim/file_codec.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2012-01-17 18:25:50 +0100
committerHarald Welte <laforge@gnumonks.org>2014-10-26 19:09:22 +0100
commitd54c2ee8c51b41b7f7a5a469efd6bb391a0c2b75 (patch)
tree2c468db6b7a0818dcc11c1e1dbd0eae5d5b27cd6 /src/sim/file_codec.c
parentcac3cd6fcd941ae0906e5a95a1cb3b5ebec8a72a (diff)
initial checkin of 'libosmosim'
Diffstat (limited to 'src/sim/file_codec.c')
-rw-r--r--src/sim/file_codec.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/sim/file_codec.c b/src/sim/file_codec.c
new file mode 100644
index 00000000..5bf5bc68
--- /dev/null
+++ b/src/sim/file_codec.c
@@ -0,0 +1,34 @@
+
+#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);
+}
+
+