2 * This file is part of libsamsung-ipc.
4 * Copyright (C) 2010-2011 Joerie de Gram <j.de.gram@gmail.com>
5 * Copyright (C) 2012 Simon Busch <morphis@gravedo.de>
6 * Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr>
8 * libsamsung-ipc is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
13 * libsamsung-ipc is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with libsamsung-ipc. If not, see <http://www.gnu.org/licenses/>.
24 #ifndef __SAMSUNG_IPC_H__
25 #define __SAMSUNG_IPC_H__
31 #define IPC_CLIENT_TYPE_FMT 0x00
32 #define IPC_CLIENT_TYPE_RFS 0x01
41 struct ipc_fmt_header;
42 struct ipc_rfs_header;
47 unsigned short command;
53 struct ipc_client_gprs_capabilities {
54 unsigned int cid_count;
66 int ipc_device_detect(void);
68 struct ipc_client *ipc_client_create(int type);
69 int ipc_client_destroy(struct ipc_client *client);
71 int ipc_client_transport_handlers_register(struct ipc_client *client,
72 int (*open)(void *transport_data, int type),
73 int (*close)(void *transport_data),
74 int (*read)(void *transport_data, void *data, size_t size),
75 int (*write)(void *transport_data, const void *data, size_t size),
76 int (*poll)(void *transport_data, struct ipc_poll_fds *fds, struct timeval *timeout),
77 void *transport_data);
78 int ipc_client_power_handlers_register(struct ipc_client *client,
79 int (*power_on)(void *power_data), int (*power_off)(void *power_data),
81 int ipc_client_gprs_handlers_register(struct ipc_client *client,
82 int (*gprs_activate)(void *gprs_data, unsigned int cid),
83 int (*gprs_deactivate)(void *gprs_data, unsigned int cid), void *gprs_data);
85 void ipc_client_log(struct ipc_client *client, const char *message, ...);
86 int ipc_client_log_callback_register(struct ipc_client *client,
87 void (*log_callback)(void *log_data, const char *message), void *log_data);
89 int ipc_client_boot(struct ipc_client *client);
90 int ipc_client_send(struct ipc_client *client, unsigned char mseq,
91 unsigned short command, unsigned char type, const void *data, size_t size);
92 int ipc_client_recv(struct ipc_client *client, struct ipc_message *message);
94 int ipc_client_open(struct ipc_client *client);
95 int ipc_client_close(struct ipc_client *client);
96 int ipc_client_poll(struct ipc_client *client, struct ipc_poll_fds *fds, struct timeval *timeout);
97 int ipc_client_power_on(struct ipc_client *client);
98 int ipc_client_power_off(struct ipc_client *client);
99 int ipc_client_gprs_activate(struct ipc_client *client, unsigned int cid);
100 int ipc_client_gprs_deactivate(struct ipc_client *client, unsigned int cid);
101 int ipc_client_data_create(struct ipc_client *client);
102 int ipc_client_data_destroy(struct ipc_client *client);
104 char *ipc_client_gprs_get_iface(struct ipc_client *client, unsigned int cid);
105 int ipc_client_gprs_get_capabilities(struct ipc_client *client,
106 struct ipc_client_gprs_capabilities *capabilities);
108 char *ipc_client_nv_data_path(struct ipc_client *client);
109 char *ipc_client_nv_data_md5_path(struct ipc_client *client);
110 char *ipc_client_nv_data_backup_path(struct ipc_client *client);
111 char *ipc_client_nv_data_backup_md5_path(struct ipc_client *client);
112 char *ipc_client_nv_data_secret(struct ipc_client *client);
113 size_t ipc_client_nv_data_size(struct ipc_client *client);
114 size_t ipc_client_nv_data_chunk_size(struct ipc_client *client);
116 int ipc_seq_valid(unsigned char seq);
118 const char *ipc_request_type_string(unsigned char type);
119 const char *ipc_response_type_string(unsigned char type);
120 const char *ipc_command_string(unsigned short command);
122 int ipc_data_dump(struct ipc_client *client, const void *data, size_t size);
123 void ipc_client_log_send(struct ipc_client *client, struct ipc_message *message,
125 void ipc_client_log_recv(struct ipc_client *client, struct ipc_message *message,
128 int ipc_fmt_header_setup(struct ipc_fmt_header *header,
129 const struct ipc_message *message);
130 int ipc_fmt_message_setup(const struct ipc_fmt_header *header,
131 struct ipc_message *message);
132 int ipc_rfs_header_setup(struct ipc_rfs_header *header,
133 const struct ipc_message *message);
134 int ipc_rfs_message_setup(const struct ipc_rfs_header *header,
135 struct ipc_message *message);
137 void *file_data_read(const char *path, size_t size, size_t chunk_size,
138 unsigned int offset);
139 int file_data_write(const char *path, const void *data, size_t size,
140 size_t chunk_size, unsigned int offset);
141 int network_iface_up(const char *iface, int domain, int type);
142 int network_iface_down(const char *iface, int domain, int type);
143 int sysfs_value_read(const char *path);
144 int sysfs_value_write(const char *path, int value);
145 char *sysfs_string_read(const char *path, size_t length);
146 int sysfs_string_write(const char *path, const char *buffer, size_t length);
147 size_t data2string_length(const void *data, size_t size);
148 char *data2string(const void *data, size_t size);
149 size_t string2data_size(const char *string);
150 void *string2data(const char *string);
153 * Samsung-IPC protocol
156 #include "protocol.h"
176 // vim:ts=4:sw=4:expandtab