aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net.h8
-rw-r--r--samsung-ipc/net.c40
2 files changed, 47 insertions, 1 deletions
diff --git a/include/net.h b/include/net.h
index c70bb2b..390541e 100644
--- a/include/net.h
+++ b/include/net.h
@@ -64,6 +64,9 @@
#define IPC_NET_PLMN_STATUS_CURRENT 0x03
#define IPC_NET_PLMN_STATUS_FORBIDDEN 0x04
+#define IPC_NET_PLMN_TYPE_EMERGENCY 0x01
+#define IPC_NET_PLMN_TYPE_NORMAL 0x04
+
#define IPC_NET_SERVICE_DOMAIN_GSM 0x02
#define IPC_NET_SERVICE_DOMAIN_GPRS 0x03
@@ -101,7 +104,7 @@ struct ipc_net_plmn_list_header {
struct ipc_net_plmn_list_entry {
unsigned char status; // IPC_NET_PLMN_STATUS
char plmn[6];
- unsigned char type;
+ unsigned char type; // IPC_NET_PLMN_TYPE
unsigned char unknown[2];
} __attribute__((__packed__));
@@ -132,6 +135,9 @@ int ipc_net_plmn_sel_setup(struct ipc_net_plmn_sel_request_data *data,
unsigned char mode_sel, const char *plmn, unsigned char act);
int ipc_net_regist_setup(struct ipc_net_regist_request_data *data,
unsigned char domain);
+unsigned char ipc_net_plmn_list_count_extract(const void *data, size_t size);
+struct ipc_net_plmn_list_entry *ipc_net_plmn_list_entry_extract(const void *data,
+ size_t size, unsigned int index);
#endif
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