14b62af5a5593ec3cc48af7b7e9c5740b9d4a220
[platform/upstream/dbus.git] / dbus / kdbus-common.h
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /* kdbus-common.h  kdbus related utils for daemon and libdbus
3  *
4  * Copyright (C) 2013  Samsung Electronics
5  *
6  * Licensed under the Academic Free License version 2.1
7  *
8  * This program 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 and under the terms of the GNU
12  * Lesser General Public License as published by the
13  * Free Software Foundation; either version 2.1 of the License, or (at
14  * your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
24  *
25  */
26
27 #ifndef KDBUS_COMMON_H_
28 #define KDBUS_COMMON_H_
29
30 #include <dbus/dbus-types.h>
31 #include <dbus/dbus-transport.h>
32 #include <dbus/kdbus.h>
33
34 #define KDBUS_ALIGN8(l) (((l) + 7) & ~7)
35 #define KDBUS_PART_NEXT(part) \
36         (typeof(part))(((uint8_t *)part) + KDBUS_ALIGN8((part)->size))
37 #define KDBUS_MSG_MAX_PAYLOAD_VEC_SIZE  0x00800000              /* maximum size of message header and items */
38 #define KDBUS_ITEM_HEADER_SIZE          offsetof(struct kdbus_item, data)
39 #define KDBUS_ITEM_SIZE(s) KDBUS_ALIGN8((s) + KDBUS_ITEM_HEADER_SIZE)
40
41 //todo restore if DBus policy will be applied in kdbus somehow
42 //#define POLICY_TO_KDBUS
43
44 dbus_bool_t register_kdbus_policy(const char* name, DBusTransport *transport, unsigned long int uid);
45 int request_kdbus_name(int fd, const char *name, const __u64 flags, __u64 id);
46 int release_kdbus_name(int fd, const char *name, __u64 id);
47
48 #endif /* KDBUS_COMMON_H_ */