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 {
61 int ipc_device_detect(void);
63 struct ipc_client *ipc_client_create(int type);
64 int ipc_client_destroy(struct ipc_client *client);
66 int ipc_client_transport_handlers_register(struct ipc_client *client,
67 int (*open)(void *transport_data, int type),
68 int (*close)(void *transport_data),
69 int (*read)(void *transport_data, void *data, size_t size),
70 int (*write)(void *transport_data, const void *data, size_t size),
71 int (*poll)(void *transport_data, struct timeval *timeout),
72 void *transport_data);
73 int ipc_client_power_handlers_register(struct ipc_client *client,
74 int (*power_on)(void *power_data), int (*power_off)(void *power_data),
76 int ipc_client_gprs_handlers_register(struct ipc_client *client,
77 int (*gprs_activate)(void *gprs_data, int cid),
78 int (*gprs_deactivate)(void *gprs_data, int cid), void *gprs_data);
80 void ipc_client_log(struct ipc_client *client, const char *message, ...);
81 int ipc_client_log_callback_register(struct ipc_client *client,
82 void (*log_callback)(void *log_data, const char *message), void *log_data);
84 int ipc_client_boot(struct ipc_client *client);
85 int ipc_client_send(struct ipc_client *client, unsigned char mseq,
86 unsigned short command, unsigned char type, const void *data, size_t size);
87 int ipc_client_recv(struct ipc_client *client, struct ipc_message *message);
89 int ipc_client_open(struct ipc_client *client);
90 int ipc_client_close(struct ipc_client *client);
91 int ipc_client_poll(struct ipc_client *client, struct timeval *timeout);
92 int ipc_client_power_on(struct ipc_client *client);
93 int ipc_client_power_off(struct ipc_client *client);
94 int ipc_client_gprs_activate(struct ipc_client *client, int cid);
95 int ipc_client_gprs_deactivate(struct ipc_client *client, int cid);
96 int ipc_client_data_create(struct ipc_client *client);
97 int ipc_client_data_destroy(struct ipc_client *client);
99 char *ipc_client_gprs_get_iface(struct ipc_client *client, int cid);
100 int ipc_client_gprs_get_capabilities(struct ipc_client *client,
101 struct ipc_client_gprs_capabilities *capabilities);
103 char *ipc_client_nv_data_path(struct ipc_client *client);
104 char *ipc_client_nv_data_md5_path(struct ipc_client *client);
105 char *ipc_client_nv_data_backup_path(struct ipc_client *client);
106 char *ipc_client_nv_data_backup_md5_path(struct ipc_client *client);
107 char *ipc_client_nv_data_secret(struct ipc_client *client);
108 size_t ipc_client_nv_data_size(struct ipc_client *client);
109 size_t ipc_client_nv_data_chunk_size(struct ipc_client *client);
111 int ipc_seq_valid(unsigned char seq);
113 const char *ipc_request_type_string(unsigned char type);
114 const char *ipc_response_type_string(unsigned char type);
115 const char *ipc_command_string(unsigned short command);
117 int ipc_data_dump(struct ipc_client *client, const void *data, size_t size);
118 void ipc_client_log_send(struct ipc_client *client, struct ipc_message *message,
120 void ipc_client_log_recv(struct ipc_client *client, struct ipc_message *message,
123 int ipc_fmt_header_setup(struct ipc_fmt_header *header,
124 const struct ipc_message *message);
125 int ipc_fmt_message_setup(const struct ipc_fmt_header *header,
126 struct ipc_message *message);
127 int ipc_rfs_header_setup(struct ipc_rfs_header *header,
128 const struct ipc_message *message);
129 int ipc_rfs_message_setup(const struct ipc_rfs_header *header,
130 struct ipc_message *message);
132 void *file_data_read(const char *path, size_t size, size_t chunk_size,
134 int file_data_write(const char *path, const void *data, size_t size,
135 size_t chunk_size, size_t offset);
136 int network_iface_up(const char *iface, int domain, int type);
137 int network_iface_down(const char *iface, int domain, int type);
138 int sysfs_value_read(const char *path);
139 int sysfs_value_write(const char *path, int value);
140 char *sysfs_string_read(const char *path, size_t length);
141 int sysfs_string_write(const char *path, const char *buffer, size_t length);
142 size_t data2string_length(const void *data, size_t size);
143 char *data2string(const void *data, size_t size);
144 size_t string2data_size(const char *string);
145 void *string2data(const char *string);
148 * Samsung-IPC protocol
151 #include "protocol.h"
171 // vim:ts=4:sw=4:expandtab