summaryrefslogtreecommitdiffstats
path: root/src/driver.h
blob: 8d12d96aa077d69648696b63d0114cc2bd0017da (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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
/*
 *
 *  oFono - Open Source Telephony
 *
 *  Copyright (C) 2008-2009  Intel Corporation. All rights reserved.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2 as
 *  published by the Free Software Foundation.
 *
 *  This program 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 this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

struct ofono_modem;

#define OFONO_MAX_PHONE_NUMBER_LENGTH 20
struct ofono_phone_number {
	char number[OFONO_MAX_PHONE_NUMBER_LENGTH + 1];
	int type;
};

/* 27.007 Section 6.2 */
enum ofono_clir_option {
	OFONO_CLIR_OPTION_DEFAULT = 0,
	OFONO_CLIR_OPTION_INVOCATION,
	OFONO_CLIR_OPTION_SUPPRESSION
};

/* 27.007 Section 6.2 */
enum ofono_cug_option {
	OFONO_CUG_OPTION_DEFAULT = 0,
	OFONO_CUG_OPTION_INVOCATION = 1,
};

enum ofono_error_type {
	OFONO_ERROR_TYPE_NO_ERROR = 0,
	OFONO_ERROR_TYPE_CME,
	OFONO_ERROR_TYPE_CMS,
	OFONO_ERROR_TYPE_CEER,
	OFONO_ERROR_TYPE_FAILURE
};

struct ofono_error {
	enum ofono_error_type type;
	int error;
};

enum ofono_disconnect_reason {
	OFONO_DISCONNECT_REASON_UNKNOWN = 0,
	OFONO_DISCONNECT_REASON_LOCAL_HANGUP,
	OFONO_DISCONNECT_REASON_REMOTE_HANGUP,
	OFONO_DISCONNECT_REASON_ERROR,
};

struct ofono_call {
	unsigned id;
	int type;
	int direction;
	int status;
	struct ofono_phone_number phone_number;
	int clip_validity;
};

/* Theoretical limit is 16, but each GSM char can be encoded into
 *  * 3 UTF8 characters resulting in 16*3=48 chars
 *   */
#define OFONO_MAX_OPERATOR_NAME_LENGTH 63

/* MCC is always three digits. MNC is either two or three digits */
#define OFONO_MAX_MCC_LENGTH 3
#define OFONO_MAX_MNC_LENGTH 3

struct ofono_network_operator {
	char name[OFONO_MAX_OPERATOR_NAME_LENGTH + 1];
	char mcc[OFONO_MAX_MCC_LENGTH + 1];
	char mnc[OFONO_MAX_MNC_LENGTH + 1];
	int status;
	int tech;
};

/* 27.007 Section 7.11 Call Forwarding */
struct ofono_cf_condition {
	int status;
	int cls;
	struct ofono_phone_number phone_number;
	int time;
};

/* 27.007 Section 7.1 Subscriber Number */
struct ofono_own_number {
	struct ofono_phone_number phone_number;
	int speed;
	int service;
	int itc;
	int npi;
};

/* 24.008 Section 10.5.4.7 */
enum ofono_number_type {
	OFONO_NUMBER_TYPE_UNKNOWN = 0,
	OFONO_NUMBER_TYPE_INTERNATIONAL = 1,
	OFONO_NUMBER_TYPE_NATIONAL = 2,
	OFONO_NUMBER_TYPE_NETWORK_SPECIFIC = 3,
	OFONO_NUMBER_TYPE_DEDICATED_ACCESS = 4,
	OFONO_NUMBER_TYPE_RESERVED = 7
};

enum ofono_numbering_plan {
	OFONO_NUMBERING_PLAN_UNKNOWN = 0,
	OFONO_NUMBERING_PLAN_ISDN = 1,
	OFONO_NUMBERING_PLAN_DATA = 3,
	OFONO_NUMBERING_PLAN_TELEX = 4,
	OFONO_NUMBERING_PLAN_NATIONAL = 8,
	OFONO_NUMBERING_PLAN_PRIVATE = 9,
	OFONO_NUMBERING_PLAN_RESERVED_CTS = 11,
	OFONO_NUMBERING_PLAN_RESERVED = 15
};

/* 51.011 Section 9.3 */
enum ofono_sim_file_structure {
	OFONO_SIM_FILE_STRUCTURE_TRANSPARENT = 0,
	OFONO_SIM_FILE_STRUCTURE_FIXED = 1,
	OFONO_SIM_FILE_STRUCTURE_CYCLIC = 3
};

/* Notification functions, the integer values here should map to
 * values obtained from the modem.  The enumerations are the same
 * as the values for the fields found in 3GPP TS 27.007
 *
 * Pass in the integer value -1 if the value is not known
 * Pass in NULL string value if the value is not known
 */
typedef void (*ofono_generic_cb_t)(const struct ofono_error *error,
					void *data);

typedef void (*ofono_call_list_cb_t)(const struct ofono_error *error,
					int numcalls,
					const struct ofono_call *call_list,
					void *data);

typedef void (*ofono_current_operator_cb_t)(const struct ofono_error *error,
					const struct ofono_network_operator *op,
					void *data);

typedef void (*ofono_operator_list_cb_t)(const struct ofono_error *error,
					int total,
					const struct ofono_network_operator *list,
					void *data);

typedef void (*ofono_registration_status_cb_t)(const struct ofono_error *error,
					int status, int lac, int ci, int tech,
					void *data);

typedef void (*ofono_signal_strength_cb_t)(const struct ofono_error *error,
					int strength, void *data);

typedef void (*ofono_call_forwarding_query_cb_t)(const struct ofono_error *error,
					int total,
					const struct ofono_cf_condition *list,
					void *data);

typedef void (*ofono_modem_attribute_query_cb_t)(const struct ofono_error *error,
					const char *attribute, void *data);

typedef void (*ofono_call_setting_status_cb_t)(const struct ofono_error *error,
						int status, void *data);

typedef void (*ofono_clir_setting_cb_t)(const struct ofono_error *error,
					int override, int network, void *data);

typedef void (*ofono_call_waiting_status_cb_t)(const struct ofono_error *error,
						int status, void *data);

typedef void (*ofono_call_meter_query_cb_t)(const struct ofono_error *error,
					int value, void *data);

typedef void (*ofono_call_meter_puct_query_cb_t)(const struct ofono_error *error,
					const char *currency, double ppu,
					void *data);

typedef void (*ofono_call_barring_cb_t)(const struct ofono_error *error,
					int status, void *data);

typedef void (*ofono_sim_file_info_cb_t)(const struct ofono_error *error,
					int filelength,
					enum ofono_sim_file_structure structure,
					int recordlength, void *data);

typedef void (*ofono_sim_read_cb_t)(const struct ofono_error *error,
					const unsigned char *sdata, int length,
					void *data);

typedef void (*ofono_imsi_cb_t)(const struct ofono_error *error,
					const char *imsi, void *data);

typedef void (*ofono_own_numbers_cb_t)(const struct ofono_error *error, int num,
			const struct ofono_own_number *numbers, void *data);

typedef void (*ofono_sca_query_cb_t)(const struct ofono_error *error,
					const struct ofono_phone_number *ph,
					void *data);

struct ofono_modem_attribute_ops {
	void (*query_manufacturer)(struct ofono_modem *modem,
			ofono_modem_attribute_query_cb_t cb, void *data);
	void (*query_serial)(struct ofono_modem *modem,
			ofono_modem_attribute_query_cb_t cb, void *data);
	void (*query_model)(struct ofono_modem *modem,
			ofono_modem_attribute_query_cb_t cb, void *data);
	void (*query_revision)(struct ofono_modem *modem,
			ofono_modem_attribute_query_cb_t cb, void *data);
};

struct ofono_modem *ofono_modem_register(struct ofono_modem_attribute_ops *ops);
int ofono_modem_unregister(struct ofono_modem *modem);

void ofono_modem_set_userdata(struct ofono_modem *modem, void *data);
void *ofono_modem_userdata(struct ofono_modem *modem);

/* Network related functions, including registration status, operator selection
 * and signal strength indicators.
 *
 * It is up to the plugin to implement CSQ polling if the modem does not support
 * vendor extensions for signal strength notification.
 */
struct ofono_network_registration_ops {
	void (*registration_status)(struct ofono_modem *modem,
			ofono_registration_status_cb_t cb, void *data);
	void (*current_operator)(struct ofono_modem *modem,
			ofono_current_operator_cb_t cb, void *data);
	void (*list_operators)(struct ofono_modem *modem,
			ofono_operator_list_cb_t cb, void *data);
	void (*register_auto)(struct ofono_modem *modem,
			ofono_generic_cb_t cb, void *data);
	void (*register_manual)(struct ofono_modem *modem,
			const struct ofono_network_operator *oper,
			ofono_generic_cb_t cb, void *data);
	void (*deregister)(struct ofono_modem *modem,
			ofono_generic_cb_t cb, void *data);
	void (*signal_strength)(struct ofono_modem *modem,
			ofono_signal_strength_cb_t, void *data);
};

void ofono_signal_strength_notify(struct ofono_modem *modem, int strength);
void ofono_network_registration_notify(struct ofono_modem *modem, int status,
			int lac, int ci, int tech);
int ofono_network_registration_register(struct ofono_modem *modem,
				struct ofono_network_registration_ops *ops);
void ofono_network_registration_unregister(struct ofono_modem *modem);

/* Voice call related functionality, including ATD, ATA, +CHLD, CTFR, CLCC
 * and VTS.
 *
 * It is up to the plugin to implement polling of CLCC if the modem does
 * not support vendor extensions for call progress indication.
 */
struct ofono_voicecall_ops {
	void (*dial)(struct ofono_modem *modem,
			const struct ofono_phone_number *number,
			enum ofono_clir_option clir, enum ofono_cug_option cug,
			ofono_generic_cb_t cb, void *data);
	void (*answer)(struct ofono_modem *modem,
			ofono_generic_cb_t cb, void *data);
	void (*hangup)(struct ofono_modem *modem,
			ofono_generic_cb_t cb, void *data);
	void (*list_calls)(struct ofono_modem *modem,
			ofono_call_list_cb_t cb, void *data);
	void (*hold_all_active)(struct ofono_modem *modem,
			ofono_generic_cb_t cb, void *data);
	void (*release_all_held)(struct ofono_modem *modem,
			ofono_generic_cb_t cb, void *data);
	void (*set_udub)(struct ofono_modem *modem,
			ofono_generic_cb_t cb, void *data);
	void (*release_all_active)(struct ofono_modem *modem,
			ofono_generic_cb_t cb, void *data);
	void (*release_specific)(struct ofono_modem *modem, int id,
			ofono_generic_cb_t cb, void *data);
	void (*private_chat)(struct ofono_modem *modem, int id,
			ofono_generic_cb_t cb, void *data);
	void (*create_multiparty)(struct ofono_modem *modem,
			ofono_generic_cb_t cb, void *data);
	void (*transfer)(struct ofono_modem *modem,
			ofono_generic_cb_t cb, void *data);
	void (*deflect)(struct ofono_modem *modem,
			const struct ofono_phone_number *ph,
			ofono_generic_cb_t cb, void *data);
	void (*swap_without_accept)(struct ofono_modem *modem,
			ofono_generic_cb_t cb, void *data);
	void (*send_tones)(struct ofono_modem *modem, const char *tones,
			ofono_generic_cb_t cb, void *data);
};

void ofono_voicecall_notify(struct ofono_modem *modem, const struct ofono_call *call);
void ofono_voicecall_disconnected(struct ofono_modem *modem, int id,
				enum ofono_disconnect_reason reason,
				const struct ofono_error *error);

int ofono_voicecall_register(struct ofono_modem *modem, struct ofono_voicecall_ops *ops);
void ofono_voicecall_unregister(struct ofono_modem *modem);

/* SSN notifications (CSSI and CSSU).  */
void ofono_cssi_notify(struct ofono_modem *modem, int code, int index);
void ofono_cssu_notify(struct ofono_modem *modem, int code, int index,
			const struct ofono_phone_number *number);

struct ofono_call_forwarding_ops {
	void (*activation)(struct ofono_modem *modem, int type, int cls,
				ofono_generic_cb_t cb, void *data);
	void (*registration)(struct ofono_modem *modem, int type, int cls,
				const struct ofono_phone_number *number,
				int time, ofono_generic_cb_t cb, void *data);
	void (*deactivation)(struct ofono_modem *modem, int type, int cls,
				ofono_generic_cb_t cb, void *data);
	void (*erasure)(struct ofono_modem *modem, int type, int cls,
				ofono_generic_cb_t cb, void *data);
	void (*query)(struct ofono_modem *modem, int type, int cls,
				ofono_call_forwarding_query_cb_t cb, void *data);
};

int ofono_call_forwarding_register(struct ofono_modem *modem,
				struct ofono_call_forwarding_ops *ops);
void ofono_call_forwarding_unregister(struct ofono_modem *modem);

struct ofono_ussd_ops {
	void (*request)(struct ofono_modem *modem, const char *str,
				ofono_generic_cb_t cb, void *data);
	void (*cancel)(struct ofono_modem *modem,
				ofono_generic_cb_t cb, void *data);
};

void ofono_ussd_notify(struct ofono_modem *modem, int status, const char *str);
int ofono_ussd_register(struct ofono_modem *modem, struct ofono_ussd_ops *ops);
void ofono_ussd_unregister(struct ofono_modem *modem);

struct ofono_call_settings_ops {
	void (*clip_query)(struct ofono_modem *modem,
				ofono_call_setting_status_cb_t cb, void *data);
	void (*colp_query)(struct ofono_modem *modem,
				ofono_call_setting_status_cb_t cb, void *data);
	void (*clir_query)(struct ofono_modem *modem, ofono_clir_setting_cb_t cb,
				void *data);
	void (*colr_query)(struct ofono_modem *modem,
				ofono_call_setting_status_cb_t cb, void *data);
	void (*clir_set)(struct ofono_modem *modem, int mode, ofono_generic_cb_t cb,
				void *data);
	void (*cw_query)(struct ofono_modem *modem, int cls,
			ofono_call_waiting_status_cb_t cb, void *data);
	void (*cw_set)(struct ofono_modem *modem, int mode, int cls,
			ofono_generic_cb_t cb, void *data);
};

int ofono_call_settings_register(struct ofono_modem *modem,
				struct ofono_call_settings_ops *ops);
void ofono_call_settings_unregister(struct ofono_modem *modem);

struct ofono_call_meter_ops {
	void (*call_meter_query)(struct ofono_modem *modem,
			ofono_call_meter_query_cb_t cb, void *data);
	void (*acm_query)(struct ofono_modem *modem,
			ofono_call_meter_query_cb_t cb, void *data);
	void (*acm_reset)(struct ofono_modem *modem, const char *sim_pin2,
			ofono_generic_cb_t cb, void *data);
	void (*acm_max_query)(struct ofono_modem *modem,
			ofono_call_meter_query_cb_t cb, void *data);
	void (*acm_max_set)(struct ofono_modem *modem, int new_value,
			const char *sim_pin2, ofono_generic_cb_t cb, void *data);
	void (*puct_query)(struct ofono_modem *modem,
			ofono_call_meter_puct_query_cb_t cb, void *data);
	void (*puct_set)(struct ofono_modem *modem, const char *currency,
			double ppu, const char *sim_pin2,
			ofono_generic_cb_t cb, void *data);
};

int ofono_call_meter_register(struct ofono_modem *modem,
				struct ofono_call_meter_ops *ops);
void ofono_call_meter_unregister(struct ofono_modem *modem);
void ofono_call_meter_maximum_notify(struct ofono_modem *modem);
void ofono_call_meter_changed_notify(struct ofono_modem *modem, int new_value);

struct ofono_call_barring_ops {
	void (*set)(struct ofono_modem *modem, const char *lock,
			int enable, const char *passwd, int cls,
			ofono_generic_cb_t cb, void *data);
	void (*query)(struct ofono_modem *modem, const char *lock, int cls,
			ofono_call_barring_cb_t cb, void *data);
};

int ofono_call_barring_register(struct ofono_modem *modem,
				struct ofono_call_barring_ops *ops);
void ofono_call_barring_unregister(struct ofono_modem *modem);

struct ofono_sim_ops {
	void (*read_file_info)(struct ofono_modem *modem, int fileid,
			ofono_sim_file_info_cb_t cb, void *data);
	void (*read_file_transparent)(struct ofono_modem *modem, int fileid,
			int start, int length,
			ofono_sim_read_cb_t cb, void *data);
	void (*read_file_linear)(struct ofono_modem *modem, int fileid,
			int record, int length,
			ofono_sim_read_cb_t cb, void *data);
	void (*write_file_transparent)(struct ofono_modem *modem, int fileid,
			int start, int length, const unsigned char *value,
			ofono_generic_cb_t cb, void *data);
	void (*write_file_linear)(struct ofono_modem *modem, int fileid,
			int record, int length, const unsigned char *value,
			ofono_generic_cb_t cb, void *data);
	void (*read_imsi)(struct ofono_modem *modem,
			ofono_imsi_cb_t cb, void *data);
	void (*read_own_numbers)(struct ofono_modem *modem,
			ofono_own_numbers_cb_t cb, void *data);
};

int ofono_sim_manager_register(struct ofono_modem *modem,
				struct ofono_sim_ops *ops);
void ofono_sim_manager_unregister(struct ofono_modem *modem);

struct ofono_sms_ops {
	void (*sca_query)(struct ofono_modem *modem, ofono_sca_query_cb_t cb,
				void *data);
	void (*sca_set)(struct ofono_modem *modem,
				const struct ofono_phone_number *sca,
				ofono_generic_cb_t cb, void *data);
};

int ofono_sms_manager_register(struct ofono_modem *modem,
				struct ofono_sms_ops *ops);
void ofono_sms_manager_unregister(struct ofono_modem *modem);

void ofono_sms_deliver_notify(struct ofono_modem *modem, unsigned char *pdu,
				int len, int tpdu_len);
void ofono_sms_status_notify(struct ofono_modem *modem, unsigned char *pdu,
				int len, int tpdu_len);

/* Export entries reports results through ofono_phonebook_entry, if an error
 * occurs, ofono_phonebook_entry should not be called
 */
struct ofono_phonebook_ops {
	void (*export_entries)(struct ofono_modem *modem, const char *storage,
				ofono_generic_cb_t cb, void *data);
};

int ofono_phonebook_register(struct ofono_modem *modem,
			     struct ofono_phonebook_ops *ops);
void ofono_phonebook_unregister(struct ofono_modem *modem);

void ofono_phonebook_entry(struct ofono_modem *modem, int index,
				const char *number, int type,
				const char *text, int hidden,
				const char *group,
				const char *adnumber, int adtype,
				const char *secondtext, const char *email,
				const char *sip_uri, const char *tel_uri);