Upgrade ofono to 1.2
[profile/ivi/ofono.git] / gisi / message.h
1 /*
2  *
3  *  oFono - Open Source Telephony
4  *
5  *  Copyright (C) 2009-2010  Nokia Corporation and/or its subsidiary(-ies).
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License version 2 as
9  *  published by the Free Software Foundation.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  */
21
22 #ifndef __GISI_MESSAGE_H
23 #define __GISI_MESSAGE_H
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #include <stdint.h>
30 #include <glib.h>
31
32 #include "phonet.h"
33
34 struct _GIsiVersion {
35         int major;
36         int minor;
37 };
38 typedef struct _GIsiVersion GIsiVersion;
39
40 struct _GIsiMessage {
41         struct sockaddr_pn *addr;
42         GIsiVersion *version;
43         int error;
44         const void *__restrict data;
45         size_t len;
46         void *private;
47 };
48 typedef struct _GIsiMessage GIsiMessage;
49
50 int g_isi_msg_version_major(const GIsiMessage *msg);
51 int g_isi_msg_version_minor(const GIsiMessage *msg);
52 int g_isi_msg_error(const GIsiMessage *msg);
53 const char *g_isi_msg_strerror(const GIsiMessage *msg);
54 uint8_t g_isi_msg_resource(const GIsiMessage *msg);
55 uint16_t g_isi_msg_object(const GIsiMessage *msg);
56
57 uint8_t g_isi_msg_id(const GIsiMessage *msg);
58 uint8_t g_isi_msg_utid(const GIsiMessage *msg);
59 size_t g_isi_msg_data_len(const GIsiMessage *msg);
60 const void *g_isi_msg_data(const GIsiMessage *msg);
61
62 gboolean g_isi_msg_data_get_byte(const GIsiMessage *msg, unsigned offset,
63                                         uint8_t *byte);
64 gboolean g_isi_msg_data_get_word(const GIsiMessage *msg, unsigned offset,
65                                         uint16_t *word);
66 gboolean g_isi_msg_data_get_struct(const GIsiMessage *msg, unsigned offset,
67                                         const void **type, size_t len);
68
69 #ifdef __cplusplus
70 }
71 #endif
72
73 #endif /* __GISI_MESSAGE_H */