aboutsummaryrefslogtreecommitdiffstats
path: root/include/samsung-ipc.h
blob: a706f9772e84d0f753dc2449964658b8322e6a15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*
 * This file is part of libsamsung-ipc.
 *
 * 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
 * the Free Software Foundation, either version 2 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 <time.h>

#ifndef __SAMSUNG_IPC_H__
#define __SAMSUNG_IPC_H__

/*
 * Values
 */

#define IPC_CLIENT_TYPE_FMT                                     0x00
#define IPC_CLIENT_TYPE_RFS                                     0x01

/*
 * Structures
 */

struct ipc_client;
struct ipc_handlers;

struct ipc_fmt_header;
struct ipc_rfs_header;

struct ipc_message {
    unsigned char mseq;
    unsigned char aseq;
    unsigned short command;
    unsigned char type;
    void *data;
    size_t size;
};

struct ipc_client_gprs_capabilities {
    int cid_count;
};

/*
 * Helpers
 */

int ipc_device_detect(void);

struct ipc_client *ipc_client_create(int type);
int ipc_client_destroy(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 *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_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_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);

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_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);

char *ipc_client_gprs_get_iface(struct ipc_client *client, int cid);
int ipc_client_gprs_get_capabilities(struct ipc_client *client,
    struct ipc_client_gprs_capabilities *capabilities);

char *ipc_client_nv_data_path(struct ipc_client *client);
char *ipc_client_nv_data_md5_path(struct ipc_client *client);
char *ipc_client_nv_data_backup_path(struct ipc_client *client);
char *ipc_client_nv_data_backup_md5_path(struct ipc_client *client);
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);

int ipc_seq_valid(unsigned char seq);

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_send(struct ipc_client *client, struct ipc_message *message,
    const char *prefix);
void ipc_client_log_recv(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
 */

#include "protocol.h"
#include "pwr.h"
#include "call.h"
#include "sms.h"
#include "sec.h"
#include "pb.h"
#include "disp.h"
#include "net.h"
#include "snd.h"
#include "misc.h"
#include "svc.h"
#include "ss.h"
#include "gprs.h"
#include "sat.h"
#include "imei.h"
#include "rfs.h"
#include "gen.h"

#endif

// vim:ts=4:sw=4:expandtab