diff options
author | Paul Kocialkowski <contact@paulk.fr> | 2014-02-15 20:16:19 +0100 |
---|---|---|
committer | Paul Kocialkowski <contact@paulk.fr> | 2014-02-15 20:58:20 +0100 |
commit | 005645221f3d4dd432970f8f28d9092d66d61213 (patch) | |
tree | 6ff93168ae04da425313ada33631fee507cfd7da /include | |
parent | ec82c3a5350b8747e1c0a7a0393ab0374dd9fbd5 (diff) | |
download | external_libsamsung-ipc-005645221f3d4dd432970f8f28d9092d66d61213.zip external_libsamsung-ipc-005645221f3d4dd432970f8f28d9092d66d61213.tar.gz external_libsamsung-ipc-005645221f3d4dd432970f8f28d9092d66d61213.tar.bz2 |
ipc: Consistent coding style and major cleanup
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Diffstat (limited to 'include')
-rw-r--r-- | include/protocol.h | 7 | ||||
-rw-r--r-- | include/samsung-ipc.h | 86 |
2 files changed, 46 insertions, 47 deletions
diff --git a/include/protocol.h b/include/protocol.h index 1de64df..d2b58d0 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -2,6 +2,7 @@ * This file is part of libsamsung-ipc. * * Copyright (C) 2010-2011 Joerie de Gram <j.de.gram@gmail.com> + * Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr> * * 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 @@ -66,9 +67,9 @@ * Macros */ -#define IPC_COMMAND(f) ((f->group << 8) | f->index) -#define IPC_GROUP(m) (m >> 8) -#define IPC_INDEX(m) (m & 0xff) +#define IPC_COMMAND(group, index) ((group << 8) | index) +#define IPC_GROUP(command) (command >> 8) +#define IPC_INDEX(command) (command & 0xff) /* * Structures diff --git a/include/samsung-ipc.h b/include/samsung-ipc.h index 13370c8..669d4d8 100644 --- a/include/samsung-ipc.h +++ b/include/samsung-ipc.h @@ -3,6 +3,7 @@ * * Copyright (C) 2010-2011 Joerie de Gram <j.de.gram@gmail.com> * Copyright (C) 2012 Simon Busch <morphis@gravedo.de> + * Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr> * * 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 @@ -40,67 +41,58 @@ struct ipc_handlers; struct ipc_fmt_header; struct ipc_rfs_header; -struct ipc_message_info { +struct ipc_message { unsigned char mseq; unsigned char aseq; - unsigned char group; - unsigned char index; - unsigned short cmd; + unsigned short command; unsigned char type; - unsigned int length; - unsigned char *data; + void *data; + size_t size; }; struct ipc_client_gprs_capabilities { - int port_list; - int cid_max; + int cid_count; }; /* * Helpers */ -struct ipc_client *ipc_client_create(int client_type); -int ipc_client_destroy(struct ipc_client *client); +int ipc_device_detect(void); -void ipc_client_log(struct ipc_client *client, const char *message, ...); -int ipc_client_set_log_callback(struct ipc_client *client, - void (*log_callback)(void *log_data, const char *message), void *log_data); +struct ipc_client *ipc_client_create(int type); +int ipc_client_destroy(struct ipc_client *client); -int ipc_client_set_transport_handlers(struct ipc_client *client, +int ipc_client_transport_handlers_register(struct ipc_client *client, int (*open)(void *transport_data, int type), int (*close)(void *transport_data), - int (*read)(void *transport_data, void *buffer, unsigned int length), - int (*write)(void *transport_data, void *buffer, unsigned int length), + int (*read)(void *transport_data, void *data, size_t size), + int (*write)(void *transport_data, const void *data, size_t size), int (*poll)(void *transport_data, struct timeval *timeout), void *transport_data); -int ipc_client_set_power_handlers(struct ipc_client *client, - int (*power_on)(void *power_data), - int (*power_off)(void *power_data), +int ipc_client_power_handlers_register(struct ipc_client *client, + int (*power_on)(void *power_data), int (*power_off)(void *power_data), void *power_data); -int ipc_client_set_gprs_handlers(struct ipc_client *client, +int ipc_client_gprs_handlers_register(struct ipc_client *client, int (*gprs_activate)(void *gprs_data, int cid), - int (*gprs_deactivate)(void *gprs_data, int cid), - void *gprs_data); + int (*gprs_deactivate)(void *gprs_data, int cid), void *gprs_data); + +void ipc_client_log(struct ipc_client *client, const char *message, ...); +int ipc_client_log_callback_register(struct ipc_client *client, + void (*log_callback)(void *log_data, const char *message), void *log_data); -int ipc_client_bootstrap(struct ipc_client *client); -int ipc_client_send(struct ipc_client *client, const unsigned short command, - const char type, unsigned char *data, const int length, unsigned char mseq); -int ipc_client_recv(struct ipc_client *client, - struct ipc_message_info *response); -void ipc_client_response_free(struct ipc_client *client, - struct ipc_message_info *response); +int ipc_client_boot(struct ipc_client *client); +int ipc_client_send(struct ipc_client *client, unsigned char mseq, + unsigned short command, unsigned char type, const void *data, size_t size); +int ipc_client_recv(struct ipc_client *client, struct ipc_message *message); int ipc_client_open(struct ipc_client *client); int ipc_client_close(struct ipc_client *client); int ipc_client_poll(struct ipc_client *client, struct timeval *timeout); - int ipc_client_power_on(struct ipc_client *client); int ipc_client_power_off(struct ipc_client *client); - int ipc_client_gprs_activate(struct ipc_client *client, int cid); int ipc_client_gprs_deactivate(struct ipc_client *client, int cid); - int ipc_client_data_create(struct ipc_client *client); int ipc_client_data_destroy(struct ipc_client *client); @@ -116,18 +108,24 @@ char *ipc_client_nv_data_secret(struct ipc_client *client); size_t ipc_client_nv_data_size(struct ipc_client *client); size_t ipc_client_nv_data_chunk_size(struct ipc_client *client); -const char *ipc_response_type_to_str(int type); -const char *ipc_request_type_to_str(int type); -const char *ipc_command_to_str(int command); -void ipc_client_hex_dump(struct ipc_client *client, void *data, int size); -void ipc_client_log_recv(struct ipc_client *client, - struct ipc_message_info *response, const char *prefix); -void ipc_client_log_send(struct ipc_client *client, - struct ipc_message_info *request, const char *prefix); -void ipc_fmt_header_fill(struct ipc_fmt_header *header, struct ipc_message_info *message); -void ipc_fmt_message_fill(struct ipc_fmt_header *header, struct ipc_message_info *message); -void ipc_rfs_header_fill(struct ipc_rfs_header *header, struct ipc_message_info *message); -void ipc_rfs_message_fill(struct ipc_rfs_header *header, struct ipc_message_info *message); +const char *ipc_request_type_string(unsigned char type); +const char *ipc_response_type_string(unsigned char type); +const char *ipc_command_string(unsigned short command); + +void ipc_hex_dump(struct ipc_client *client, const void *data, size_t size); +void ipc_client_log_recv(struct ipc_client *client, struct ipc_message *message, + const char *prefix); +void ipc_client_log_send(struct ipc_client *client, struct ipc_message *message, + const char *prefix); + +int ipc_fmt_header_setup(struct ipc_fmt_header *header, + const struct ipc_message *message); +int ipc_fmt_message_setup(const struct ipc_fmt_header *header, + struct ipc_message *message); +int ipc_rfs_header_setup(struct ipc_rfs_header *header, + const struct ipc_message *message); +int ipc_rfs_message_setup(const struct ipc_rfs_header *header, + struct ipc_message *message); /* * Samsung-IPC protocol |