diff options
author | Paul Kocialkowski <contact@paulk.fr> | 2014-08-02 17:37:08 +0200 |
---|---|---|
committer | Paul Kocialkowski <contact@paulk.fr> | 2014-08-02 17:37:08 +0200 |
commit | 056cf387d88ab0a0eab0c097474d62d8c3d09c13 (patch) | |
tree | eac0ec509db69d5287808de3dccdc401827e79d1 /samsung-ipc | |
parent | 50be5571afbcc535ea67dfd76367febb1c2a8255 (diff) | |
download | external_libsamsung-ipc-056cf387d88ab0a0eab0c097474d62d8c3d09c13.zip external_libsamsung-ipc-056cf387d88ab0a0eab0c097474d62d8c3d09c13.tar.gz external_libsamsung-ipc-056cf387d88ab0a0eab0c097474d62d8c3d09c13.tar.bz2 |
net: PLMN list extract helpers, PLMN type
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Diffstat (limited to 'samsung-ipc')
-rw-r--r-- | samsung-ipc/net.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/samsung-ipc/net.c b/samsung-ipc/net.c index 0597c42..50cc18f 100644 --- a/samsung-ipc/net.c +++ b/samsung-ipc/net.c @@ -66,4 +66,44 @@ int ipc_net_regist_setup(struct ipc_net_regist_request_data *data, return 0; } +unsigned char ipc_net_plmn_list_count_extract(const void *data, size_t size) +{ + struct ipc_net_plmn_list_header *header; + + if (data == NULL || size < sizeof(struct ipc_net_plmn_list_header)) + return 0; + + header = (struct ipc_net_plmn_list_header *) data; + + return header->count; +} + +struct ipc_net_plmn_list_entry *ipc_net_plmn_list_entry_extract(const void *data, + size_t size, unsigned int index) +{ + struct ipc_net_plmn_list_entry *entry = NULL; + unsigned char count; + unsigned char i; + unsigned int offset; + + if (data == NULL) + return NULL; + + count = ipc_net_plmn_list_count_extract(data, size); + if (count == 0 || index >= count) + return NULL; + + offset = sizeof(struct ipc_net_plmn_list_header); + + for (i = 0; i < (index + 1); i++) { + entry = (struct ipc_net_plmn_list_entry *) ((unsigned char *) data + offset); + offset += sizeof(struct ipc_net_plmn_list_entry); + } + + if (offset > size) + return NULL; + + return entry; +} + // vim:ts=4:sw=4:expandtab |