aboutsummaryrefslogtreecommitdiffstats
path: root/samsung-ipc
diff options
context:
space:
mode:
authorSimon Busch <morphis@gravedo.de>2011-10-29 09:47:18 +0200
committerSimon Busch <morphis@gravedo.de>2011-10-29 09:47:18 +0200
commit4023f332abcfad3c0d0ce91d8dd51cd6134b40a0 (patch)
treeb0fcbf6946ec0e9a5bb5558eb1a1247ae7813211 /samsung-ipc
parent3fcbca9b0c1ea0e8dd2ba2d43b07f8090339755d (diff)
parent28cbef8271908eddef649f31a67dc6b0380b1802 (diff)
downloadexternal_libsamsung-ipc-4023f332abcfad3c0d0ce91d8dd51cd6134b40a0.zip
external_libsamsung-ipc-4023f332abcfad3c0d0ce91d8dd51cd6134b40a0.tar.gz
external_libsamsung-ipc-4023f332abcfad3c0d0ce91d8dd51cd6134b40a0.tar.bz2
Merge remote-tracking branch 'ius/for-morphis' into master-next
Diffstat (limited to 'samsung-ipc')
-rw-r--r--samsung-ipc/device/crespo/crespo_ipc.c (renamed from samsung-ipc/crespo_ipc.c)209
-rw-r--r--samsung-ipc/device/crespo/crespo_ipc.h (renamed from samsung-ipc/crespo_ipc.h)2
-rw-r--r--samsung-ipc/device/crespo/crespo_modem_ctl.h (renamed from samsung-ipc/crespo_modem_ctl.h)0
-rw-r--r--samsung-ipc/device/crespo/crespo_nv_data.c (renamed from samsung-ipc/crespo_nv_data.c)0
-rw-r--r--samsung-ipc/device/crespo/crespo_nv_data.h (renamed from samsung-ipc/crespo_nv_data.h)0
-rw-r--r--samsung-ipc/device/h1/h1_ipc.c (renamed from samsung-ipc/h1_ipc.c)79
-rw-r--r--samsung-ipc/device/h1/h1_ipc.h (renamed from samsung-ipc/h1_ipc.h)0
-rw-r--r--samsung-ipc/gprs.c6
-rw-r--r--samsung-ipc/ipc.c127
-rw-r--r--samsung-ipc/ipc_private.h31
-rw-r--r--samsung-ipc/ipc_util.c12
-rw-r--r--samsung-ipc/misc.c2
-rw-r--r--samsung-ipc/net.c27
-rw-r--r--samsung-ipc/sec.c6
14 files changed, 408 insertions, 93 deletions
diff --git a/samsung-ipc/crespo_ipc.c b/samsung-ipc/device/crespo/crespo_ipc.c
index 44bc676..8752ae0 100644
--- a/samsung-ipc/crespo_ipc.c
+++ b/samsung-ipc/device/crespo/crespo_ipc.c
@@ -274,6 +274,8 @@ boot_loop_start:
free(nv_data_p);
+ close(modem_ctl_fd);
+
rc = 0;
goto exit;
@@ -292,7 +294,7 @@ exit:
return rc;
}
-int crespo_ipc_client_send(struct ipc_client *client, struct ipc_request *request)
+int crespo_ipc_client_send(struct ipc_client *client, struct ipc_message_info *request)
{
struct modem_io modem_data;
struct ipc_header reqhdr;
@@ -312,11 +314,11 @@ int crespo_ipc_client_send(struct ipc_client *client, struct ipc_request *reques
modem_data.data = malloc(reqhdr.length);
memcpy(modem_data.data, &reqhdr, sizeof(struct ipc_header));
- memcpy(modem_data.data + sizeof(struct ipc_header), request->data, request->length);
+ memcpy((unsigned char *)modem_data.data + sizeof(struct ipc_header), request->data, request->length);
- assert(client->write != NULL);
+ assert(client->handlers->write != NULL);
- rc = client->write((uint8_t*) &modem_data, sizeof(struct modem_io), client->write_data);
+ rc = client->handlers->write((uint8_t*) &modem_data, sizeof(struct modem_io), client->handlers->io_data);
return rc;
}
@@ -342,7 +344,7 @@ int wake_unlock(char *lock_name, int size)
return rc;
}
-int crespo_ipc_client_recv(struct ipc_client *client, struct ipc_response *response)
+int crespo_ipc_client_recv(struct ipc_client *client, struct ipc_message_info *response)
{
struct modem_io modem_data;
struct ipc_header *resphdr;
@@ -352,13 +354,13 @@ int crespo_ipc_client_recv(struct ipc_client *client, struct ipc_response *respo
modem_data.data = malloc(MAX_MODEM_DATA_SIZE);
modem_data.size = MAX_MODEM_DATA_SIZE;
- memset(response, 0, sizeof(struct ipc_response));
+ memset(response, 0, sizeof(struct ipc_message_info));
wake_lock("secril_fmt-interface", sizeof("secril_fmt-interface") - 1); // FIXME sizeof("...") is ugly!
- assert(client->read != NULL);
- bread = client->read((uint8_t*) &modem_data, sizeof(struct modem_io) + MAX_MODEM_DATA_SIZE, client->read_data);
- if (bread <= 0)
+ assert(client->handlers->read != NULL);
+ bread = client->handlers->read((uint8_t*) &modem_data, sizeof(struct modem_io) + MAX_MODEM_DATA_SIZE, client->handlers->io_data);
+ if (bread < 0)
{
ipc_client_log(client, "ERROR: crespo_ipc_client_recv: can't receive enough bytes from modem to process incoming response!");
return 1;
@@ -372,22 +374,25 @@ int crespo_ipc_client_recv(struct ipc_client *client, struct ipc_response *respo
return 1;
}
+ /* You MUST send back modem_data */
+
resphdr = (struct ipc_header *) modem_data.data;
response->mseq = resphdr->mseq;
response->aseq = resphdr->aseq;
- response->command = IPC_COMMAND(resphdr);
+ response->group = resphdr->group;
+ response->index = resphdr->index;
response->type = resphdr->type;
- response->data_length = modem_data.size - sizeof(struct ipc_header);
+ response->length = modem_data.size - sizeof(struct ipc_header);
response->data = NULL;
- ipc_client_log(client, "INFO: crespo_ipc_client_recv: response: group = %d, index = %d, command = %04x",
- resphdr->group, resphdr->index, response->command);
+ ipc_client_log(client, "INFO: crespo_ipc_client_recv: response: group = %d, index = %d",
+ resphdr->group, resphdr->index);
- if(response->data_length > 0)
+ if(response->length > 0)
{
- response->data = malloc(response->data_length);
- memcpy(response->data, (uint8_t *) modem_data.data + sizeof(struct ipc_header), response->data_length);
+ response->data = malloc(response->length);
+ memcpy(response->data, (uint8_t *) modem_data.data + sizeof(struct ipc_header), response->length);
}
free(modem_data.data);
@@ -397,11 +402,175 @@ int crespo_ipc_client_recv(struct ipc_client *client, struct ipc_response *respo
return 0;
}
-struct ipc_ops crespo_ipc_ops = {
- .open = NULL,
- .close = NULL,
+int crespo_ipc_open(void *data, unsigned int size, void *io_data)
+{
+ int type = *((int *) data);
+ int fd = -1;
+
+ switch(type)
+ {
+ case IPC_CLIENT_TYPE_FMT:
+ fd = open("/dev/modem_fmt", O_RDWR | O_NDELAY);
+ printf("crespo_ipc_open: opening /dev/modem_fmt\n");
+ break;
+ case IPC_CLIENT_TYPE_RFS:
+ fd = open("/dev/modem_rfs", O_RDWR | O_NDELAY);
+ printf("crespo_ipc_open: opening /dev/modem_rfs\n");
+ break;
+ default:
+ break;
+ }
+
+ if(fd < 0)
+ return -1;
+
+ if(io_data == NULL)
+ return -1;
+
+ memcpy(io_data, &fd, sizeof(int));
+
+ return 0;
+}
+
+int crespo_ipc_close(void *data, unsigned int size, void *io_data)
+{
+ int fd = -1;
+
+ if(io_data == NULL)
+ return -1;
+
+ fd = *((int *) io_data);
+
+ if(fd < 0)
+ return -1;
+
+ close(fd);
+
+ return 0;
+}
+
+int crespo_ipc_read(void *data, unsigned int size, void *io_data)
+{
+ int fd = -1;
+ int rc;
+
+ if(io_data == NULL)
+ return -1;
+
+ if(data == NULL)
+ return -1;
+
+ fd = *((int *) io_data);
+
+ if(fd < 0)
+ return -1;
+
+ rc = ioctl(fd, IOCTL_MODEM_RECV, data);
+
+ if(rc < 0)
+ return -1;
+
+ return 0;
+}
+
+int crespo_ipc_write(void *data, unsigned int size, void *io_data)
+{
+ int fd = -1;
+ int rc;
+
+ if(io_data == NULL)
+ return -1;
+
+ fd = *((int *) io_data);
+
+ if(fd < 0)
+ return -1;
+
+ rc = ioctl(fd, IOCTL_MODEM_SEND, data);
+
+ if(rc < 0)
+ return -1;
+
+ return 0;
+}
+
+int crespo_ipc_power_on(void *data)
+{
+ int fd=open("/dev/modem_ctl", O_RDWR);
+ int rc;
+
+/*
+ fd = open("/sys/devices/platform/modemctl/power_mode", O_RDWR);
+ rc = write(fd, "1", 1);
+*/
+
+ if(fd < 0)
+ return -1;
+
+ rc = ioctl(fd, IOCTL_MODEM_START);
+ close(fd);
+
+ if(rc < 0)
+ return -1;
+
+ return 0;
+}
+
+int crespo_ipc_power_off(void *data)
+{
+ int fd=open("/dev/modem_ctl", O_RDWR);
+ int rc;
+
+/*
+ fd = open("/sys/devices/platform/modemctl/power_mode", O_RDWR);
+ rc = write(fd, "0", 1);
+*/
+
+ if(fd < 0)
+ return -1;
+
+ rc = ioctl(fd, IOCTL_MODEM_OFF);
+ close(fd);
+
+ if(rc < 0)
+ return -1;
+
+ return 0;
+}
+
+void *crespo_ipc_io_data_reg(void)
+{
+ void *data = NULL;
+
+ data = malloc(sizeof(int));
+
+ return data;
+}
+
+int crespo_ipc_io_data_unreg(void *data)
+{
+ if(data == NULL)
+ return -1;
+
+ free(data);
+
+ return 0;
+}
+
+struct ipc_handlers ipc_default_handlers = {
+ .read = crespo_ipc_read,
+ .write = crespo_ipc_write,
+ .open = crespo_ipc_open,
+ .close = crespo_ipc_close,
+ .io_data_reg = crespo_ipc_io_data_reg,
+ .io_data_unreg = crespo_ipc_io_data_unreg,
+ .io_data = NULL,
+ .power_on = crespo_ipc_power_on,
+ .power_off = crespo_ipc_power_off,
+};
+
+struct ipc_ops ipc_ops = {
.send = crespo_ipc_client_send,
.recv = crespo_ipc_client_recv,
.bootstrap = crespo_modem_bootstrap,
};
-
diff --git a/samsung-ipc/crespo_ipc.h b/samsung-ipc/device/crespo/crespo_ipc.h
index 7bf6abc..a6540b5 100644
--- a/samsung-ipc/crespo_ipc.h
+++ b/samsung-ipc/device/crespo/crespo_ipc.h
@@ -45,4 +45,6 @@ void *file_read(char *file_name, int size, int block_size);
int wake_lock(char *lock_name, int size);
int wake_unlock(char *lock_name, int size);
+extern struct ipc_handlers crespo_ipc_default_handlers;
+
#endif
diff --git a/samsung-ipc/crespo_modem_ctl.h b/samsung-ipc/device/crespo/crespo_modem_ctl.h
index 7c23165..7c23165 100644
--- a/samsung-ipc/crespo_modem_ctl.h
+++ b/samsung-ipc/device/crespo/crespo_modem_ctl.h
diff --git a/samsung-ipc/crespo_nv_data.c b/samsung-ipc/device/crespo/crespo_nv_data.c
index 58b034e..58b034e 100644
--- a/samsung-ipc/crespo_nv_data.c
+++ b/samsung-ipc/device/crespo/crespo_nv_data.c
diff --git a/samsung-ipc/crespo_nv_data.h b/samsung-ipc/device/crespo/crespo_nv_data.h
index bc17416..bc17416 100644
--- a/samsung-ipc/crespo_nv_data.h
+++ b/samsung-ipc/device/crespo/crespo_nv_data.h
diff --git a/samsung-ipc/h1_ipc.c b/samsung-ipc/device/h1/h1_ipc.c
index 65f48bb..601f67d 100644
--- a/samsung-ipc/h1_ipc.c
+++ b/samsung-ipc/device/h1/h1_ipc.c
@@ -25,6 +25,7 @@
#include "ipc_private.h"
#include "h1_ipc.h"
+/* FIXME: move to io_data */
static int fd = 0;
int h1_ipc_open()
@@ -50,28 +51,28 @@ int h1_ipc_close()
return close(fd);
}
- return 1;
-}
-
-int h1_ipc_fd_get()
-{
- return fd;
+ return 0;
}
-void h1_ipc_power_on()
+int h1_ipc_power_on()
{
ioctl(fd, IOCTL_PHONE_ON);
+
+ return 0;
}
-void h1_ipc_power_off()
+int h1_ipc_power_off()
{
ioctl(fd, IOCTL_PHONE_OFF);
+
+ return 0;
}
-void h1_ipc_send(struct ipc_request *request)
+int h1_ipc_send(struct ipc_client *client, struct ipc_message_info *request)
{
struct hdlc_header *hdlc;
unsigned char *frame;
+ unsigned char *payload;
int frame_length;
/* Frame length: HDLC/IPC header + payload length + HDLC flags (2) */
@@ -87,7 +88,7 @@ void h1_ipc_send(struct ipc_request *request)
hdlc->length = (sizeof(*hdlc) + request->length);
hdlc->unknown = 0;
- /* IPC data */
+ /* IPC header */
hdlc->ipc.length = (sizeof(hdlc->ipc) + request->length);
hdlc->ipc.mseq = request->mseq;
hdlc->ipc.aseq = request->aseq;
@@ -95,13 +96,24 @@ void h1_ipc_send(struct ipc_request *request)
hdlc->ipc.index = request->index;
hdlc->ipc.type = request->type;
+ /* IPC payload */
+ payload = (frame + 1 + sizeof(*hdlc));
+ memcpy(payload, request->data, request->length);
+
+ ipc_client_log(client, "sending %s %s\n",
+ ipc_command_type_to_str(IPC_COMMAND(request)),
+ ipc_response_type_to_str(request->type));
+
hex_dump(frame, frame_length);
- write(fd, frame, frame_length);
+
+ client->handlers->write(frame, frame_length, client->handlers->io_data);
free(frame);
+
+ return 0;
}
-int h1_ipc_recv(struct ipc_response *response)
+int h1_ipc_recv(struct ipc_client *client, struct ipc_message_info *response)
{
unsigned char buf[4];
unsigned char *data;
@@ -110,39 +122,64 @@ int h1_ipc_recv(struct ipc_response *response)
int num_read;
int left;
- num_read = read(fd, buf, sizeof(buf));
+ num_read = client->handlers->read((void*)buf, sizeof(buf), client->handlers->io_data);
if(num_read == sizeof(buf) && *buf == FRAME_START) {
frame_length = (unsigned short*)&buf[1];
left = (*frame_length - 3 + 1);
data = (unsigned char*)malloc(left);
- num_read = read(fd, data, left);
+ num_read = client->handlers->read((void*)data, left, client->handlers->io_data);
if(num_read == left && data[left-1] == FRAME_END) {
ipc = (struct ipc_header*)data;
response->mseq = ipc->mseq;
response->aseq = ipc->aseq;
- response->command = IPC_COMMAND(ipc);
+ response->group = ipc->group;
+ response->index = ipc->index;
response->type = ipc->type;
- response->data_length = (ipc->length - sizeof(*ipc));
+ response->length = (ipc->length - sizeof(*ipc));
+
+ response->data = (unsigned char*)malloc(response->length);
+ memcpy(response->data, (data + sizeof(*ipc)), response->length);
+
+ ipc_client_log(client, "received %s %s\n",
+ ipc_command_type_to_str(IPC_COMMAND(response)),
+ ipc_response_type_to_str(response->type));
- response->data = (unsigned char*)malloc(response->data_length);
- memcpy(response->data, (data + sizeof(*ipc)), response->data_length);
+ hex_dump(data, num_read-1);
return 0;
}
}
- return 1;
+ return 0;
+}
+
+int h1_ipc_read(void *data, unsigned int size, void *io_data)
+{
+ return read(fd, data, size);
+}
+
+int h1_ipc_write(void *data, unsigned int size, void *io_data)
+{
+ return write(fd, data, size);
}
-struct ipc_ops h1_ipc_ops = {
+struct ipc_handlers ipc_default_handlers = {
.open = h1_ipc_open,
.close = h1_ipc_close,
.power_on = h1_ipc_power_on,
.power_off = h1_ipc_power_off,
+ .read = h1_ipc_read,
+ .write = h1_ipc_write,
+ .io_data_reg = NULL,
+ .io_data_unreg = NULL,
+ .io_data = NULL,
+};
+
+struct ipc_ops ipc_ops = {
.send = h1_ipc_send,
.recv = h1_ipc_recv,
- .fd_get = h1_ipc_fd_get,
+ .bootstrap = NULL,
};
diff --git a/samsung-ipc/h1_ipc.h b/samsung-ipc/device/h1/h1_ipc.h
index 1bbc951..1bbc951 100644
--- a/samsung-ipc/h1_ipc.h
+++ b/samsung-ipc/device/h1/h1_ipc.h
diff --git a/samsung-ipc/gprs.c b/samsung-ipc/gprs.c
index 7f656a6..da39ba6 100644
--- a/samsung-ipc/gprs.c
+++ b/samsung-ipc/gprs.c
@@ -29,7 +29,7 @@ void ipc_gprs_define_pdp_context_setup(struct ipc_gprs_define_pdp_context *messa
message->unk0[0] = 0x1;
message->unk0[1] = 0x1;
message->unk0[2] = 0x2;
- strncpy(message->apn, apn, 124);
+ strncpy((char*)message->apn, apn, 124);
}
void ipc_gprs_pdp_context_setup(struct ipc_gprs_pdp_context *message, char *username, char *password)
@@ -39,6 +39,6 @@ void ipc_gprs_pdp_context_setup(struct ipc_gprs_pdp_context *message, char *user
message->unk0[1] = 0x1;
message->unk0[2] = 0x13;
message->unk2 = 0x1;
- strncpy(message->username, username, 32);
- strncpy(message->password, password, 32);
+ strncpy((char*)message->username, username, 32);
+ strncpy((char*)message->password, password, 32);
}
diff --git a/samsung-ipc/ipc.c b/samsung-ipc/ipc.c
index 9ef091c..97a0b18 100644
--- a/samsung-ipc/ipc.c
+++ b/samsung-ipc/ipc.c
@@ -29,9 +29,8 @@
#include "ipc_private.h"
-extern struct ipc_ops crespo_ipc_ops;
-// extern struct ipc_ops h1_ipc_ops;
-
+extern struct ipc_ops ipc_ops;
+extern struct ipc_handlers ipc_default_handlers;
void log_handler_default(const char *message, void *user_data)
{
@@ -54,31 +53,35 @@ void ipc_client_log(struct ipc_client *client, const char *message, ...)
struct ipc_client* ipc_client_new(int client_type)
{
struct ipc_client *client;
- struct ips_ops *ops = NULL;
+ struct ipc_ops *ops = NULL;
switch (client_type)
{
- case IPC_CLIENT_TYPE_CRESPO_FMT:
- case IPC_CLIENT_TYPE_CRESPO_RFS:
- ops = &crespo_ipc_ops;
- break;
- case IPC_CLIENT_TYPE_H1:
- // ops = &h1_ipc_ops;
+ case IPC_CLIENT_TYPE_FMT:
+ case IPC_CLIENT_TYPE_RFS:
+ ops = &ipc_ops;
break;
default:
- break;
+ return NULL;
}
client = (struct ipc_client*) malloc(sizeof(struct ipc_client));
client->type = client_type;
client->ops = ops;
+ client->handlers = (struct ipc_handlers *) malloc(sizeof(struct ipc_handlers));
client->log_handler = log_handler_default;
+ /* Set default handlers */
+ ipc_client_set_handlers(client, &ipc_default_handlers);
+
return client;
}
int ipc_client_free(struct ipc_client *client)
{
+ if(client->handlers->io_data != NULL)
+ client->handlers->io_data_unreg(client->handlers->io_data);
+ free(client->handlers);
free(client);
client = NULL;
return 0;
@@ -86,7 +89,7 @@ int ipc_client_free(struct ipc_client *client)
int ipc_client_set_log_handler(struct ipc_client *client, ipc_client_log_handler_cb log_handler_cb, void *user_data)
{
- if (client == NULL)
+ if(client == NULL)
return -1;
client->log_handler = log_handler_cb;
@@ -95,18 +98,59 @@ int ipc_client_set_log_handler(struct ipc_client *client, ipc_client_log_handler
return 0;
}
+int ipc_client_set_io_handlers(struct ipc_client *client, void *io_data,
+ ipc_io_handler_cb read, ipc_io_handler_cb write,
+ ipc_io_handler_cb open, ipc_io_handler_cb close)
+{
+ if(client == NULL)
+ return -1;
-int ipc_client_set_delegates(struct ipc_client *client,
- ipc_client_transport_cb write, void *write_data,
- ipc_client_transport_cb read, void *read_data)
+ if(read != NULL)
+ client->handlers->read = read;
+ if(write != NULL)
+ client->handlers->write = write;
+ if(open != NULL)
+ client->handlers->open = open;
+ if(close != NULL)
+ client->handlers->close = close;
+ if(io_data != NULL)
+ {
+ client->handlers->io_data = io_data;
+ if(client->handlers->io_data_reg != NULL)
+ client->handlers->io_data = client->handlers->io_data_reg();
+ }
+
+ return 0;
+}
+
+int ipc_client_set_handlers(struct ipc_client *client, struct ipc_handlers *handlers)
{
- if (client == NULL)
+ if(client == NULL)
+ return -1;
+ if(handlers == NULL)
return -1;
- client->read = read;
- client->read_data = read_data;
- client->write = write;
- client->write_data = write_data;
+ memcpy(client->handlers, handlers, sizeof(struct ipc_handlers));
+
+ if(client->handlers->io_data_reg != NULL)
+ client->handlers->io_data = client->handlers->io_data_reg();
+
+ return 0;
+}
+
+void *ipc_client_get_handlers_io_data(struct ipc_client *client)
+{
+ return client->handlers->io_data;
+}
+
+int ipc_client_set_handlers_io_data(struct ipc_client *client, void *io_data)
+{
+ if(client == NULL)
+ return -1;
+ if(io_data == NULL)
+ return -1;
+
+ client->handlers->io_data=io_data;
return 0;
}
@@ -123,25 +167,50 @@ int ipc_client_bootstrap_modem(struct ipc_client *client)
int ipc_client_open(struct ipc_client *client)
{
+ int type;
+ int fd;
+
if (client == NULL ||
- client->ops == NULL ||
- client->ops->open == NULL)
+ client->handlers == NULL ||
+ client->handlers->open == NULL)
return -1;
- return client->ops->open(client);
+ type = client->type;
+
+ return client->handlers->open(&type, 0, client->handlers->io_data);
}
int ipc_client_close(struct ipc_client *client)
{
if (client == NULL ||
- client->ops == NULL ||
- client->ops->close == NULL)
+ client->handlers == NULL ||
+ client->handlers->open == NULL)
+ return -1;
+
+ return client->handlers->close(NULL, 0, client->handlers->io_data);
+}
+
+int ipc_client_power_on(struct ipc_client *client)
+{
+ if (client == NULL ||
+ client->handlers == NULL ||
+ client->handlers->open == NULL)
+ return -1;
+
+ return client->handlers->power_on(NULL);
+}
+
+int ipc_client_power_off(struct ipc_client *client)
+{
+ if (client == NULL ||
+ client->handlers == NULL ||
+ client->handlers->open == NULL)
return -1;
- return client->ops->close(client);
+ return client->handlers->power_off(NULL);
}
-int _ipc_client_send(struct ipc_client *client, struct ipc_request *request)
+int _ipc_client_send(struct ipc_client *client, struct ipc_message_info *request)
{
if (client == NULL ||
client->ops == NULL ||
@@ -165,7 +234,7 @@ inline void ipc_client_send_exec(struct ipc_client *client, const unsigned short
/* Wrapper for ipc_send */
void ipc_client_send(struct ipc_client *client, const unsigned short command, const char type, unsigned char *data, const int length, unsigned char mseq)
{
- struct ipc_request request;
+ struct ipc_message_info request;
request.mseq = mseq;
request.aseq = 0xff;
@@ -178,7 +247,7 @@ void ipc_client_send(struct ipc_client *client, const unsigned short command, co
_ipc_client_send(client, &request);
}
-int ipc_client_recv(struct ipc_client *client, struct ipc_response *response)
+int ipc_client_recv(struct ipc_client *client, struct ipc_message_info *response)
{
if (client == NULL ||
client->ops == NULL ||
diff --git a/samsung-ipc/ipc_private.h b/samsung-ipc/ipc_private.h
index d724781..4e05119 100644
--- a/samsung-ipc/ipc_private.h
+++ b/samsung-ipc/ipc_private.h
@@ -21,31 +21,42 @@
#ifndef __IPC_PRIVATE_H__
#define __IPC_PRIVATE_H__
+#include <radio.h>
+
struct ipc_client;
void ipc_client_log(struct ipc_client *client, const char *message, ...);
struct ipc_ops {
int (*bootstrap)(struct ipc_client *client);
- int (*open)(struct ipc_client *client);
- int (*close)(struct ipc_client *client);
- int (*send)(struct ipc_client *client, struct ipc_request*);
- int (*recv)(struct ipc_client *client, struct ipc_response*);
+ int (*send)(struct ipc_client *client, struct ipc_message_info *);
+ int (*recv)(struct ipc_client *client, struct ipc_message_info *);
+};
+
+struct ipc_handlers {
+ /* Transport handlers/data */
+ ipc_io_handler_cb read;
+ ipc_io_handler_cb write;
+ ipc_io_handler_cb open;
+ ipc_io_handler_cb close;
+
+ ipc_handler_data_cb io_data_reg;
+ ipc_handler_cb io_data_unreg;
+ void *io_data;
+
+ /* Power handlers */
+ ipc_handler_cb power_on;
+ ipc_handler_cb power_off;
};
struct ipc_client {
int type;
- /* callbacks for transport handling */
- ipc_client_transport_cb read;
- void *read_data;
- ipc_client_transport_cb write;
- void *write_data;
-
ipc_client_log_handler_cb log_handler;
void *log_data;
struct ipc_ops *ops;
+ struct ipc_handlers *handlers;
};
diff --git a/samsung-ipc/ipc_util.c b/samsung-ipc/ipc_util.c
index 1f642ae..b1726e1 100644
--- a/samsung-ipc/ipc_util.c
+++ b/samsung-ipc/ipc_util.c
@@ -25,12 +25,12 @@
const char *ipc_response_type_to_str(int type) {
switch(type) {
- case IPC_TYPE_INDICATION:
- return "INDICATION";
- case IPC_TYPE_RESPONSE:
- return "RESPONSE";
- case IPC_TYPE_NOTIFICATION:
- return "NOTIFICATION";
+ case IPC_TYPE_INDI:
+ return "INDI";
+ case IPC_TYPE_RESP:
+ return "RESP";
+ case IPC_TYPE_NOTI:
+ return "NOTI";
default:
return "UNKNOWN";
}
diff --git a/samsung-ipc/misc.c b/samsung-ipc/misc.c
index 609d7b8..c4f27ee 100644
--- a/samsung-ipc/misc.c
+++ b/samsung-ipc/misc.c
@@ -23,7 +23,7 @@
#define DEFAULT_IMSI_LENGTH 15
-char* ipc_misc_me_imsi_response_get_imsi(struct ipc_response *response)
+char* ipc_misc_me_imsi_response_get_imsi(struct ipc_message_info *response)
{
if (response == NULL || response->data[0] != DEFAULT_IMSI_LENGTH)
return NULL;
diff --git a/samsung-ipc/net.c b/samsung-ipc/net.c
new file mode 100644
index 0000000..9024e86
--- /dev/null
+++ b/samsung-ipc/net.c
@@ -0,0 +1,27 @@
+/**
+ * This file is part of libsamsung-ipc.
+ *
+ * Copyright (C) 2010-2011 Joerie de Gram <j.de.gram@gmail.com
+ *
+ * libsamsung-ipc 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libsamsung-ipc 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 libsamsung-ipc. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <radio.h>
+
+void ipc_net_regist_get(struct ipc_net_regist_get *message, int domain)
+{
+ message->net = 0xff;
+ message->domain = domain;
+}
diff --git a/samsung-ipc/sec.c b/samsung-ipc/sec.c
index 9cef712..5d43a62 100644
--- a/samsung-ipc/sec.c
+++ b/samsung-ipc/sec.c
@@ -32,18 +32,18 @@ void ipc_sec_pin_status_set_setup(struct ipc_sec_pin_status_set *message,
if (pin1 != NULL)
{
- strncpy(message->pin1, pin1, 8);
+ strncpy((char*)message->pin1, pin1, 8);
message->length1 = strlen(pin1);
}
if (pin2 != NULL)
{
- strncpy(message->pin2, pin2, 8);
+ strncpy((char*)message->pin2, pin2, 8);
message->length2 = strlen(pin2);
}
}
-char* ipc_sec_rsim_access_response_get_file_data(struct ipc_response *response)
+char* ipc_sec_rsim_access_response_get_file_data(struct ipc_message_info *response)
{
int n = 0;
int offset = (int) sizeof(struct ipc_sec_rsim_access_response);