Added security-manager API
[platform/core/security/security-server.git] / src / server / client / client-common.h
1 /*
2  *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Contact: Bumjin Im <bj.im@samsung.com>
5  *
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License
17  */
18 /*
19  * @file        client-common.h
20  * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
21  * @version     1.0
22  * @brief       This file constains implementation of common types
23  *              used in security server.
24  */
25
26 #ifndef _SECURITY_SERVER_CLIENT_
27 #define _SECURITY_SERVER_CLIENT_
28
29 #include <vector>
30 #include <functional>
31
32 #include <message-buffer.h>
33
34 #define SECURITY_SERVER_API __attribute__((visibility("default")))
35 #define SECURITY_MANAGER_API __attribute__((visibility("default")))
36 #define SECURITY_SERVER_UNUSED __attribute__((unused))
37
38 extern "C" {
39     struct msghdr;
40 }
41
42 namespace SecurityServer {
43
44 typedef std::vector<unsigned char> RawBuffer;
45
46 int sendToServer(char const * const interface, const RawBuffer &send, MessageBuffer &recv);
47
48 /*
49  * sendToServerAncData is special case when we want to receive file descriptor
50  * passed by Security Server on behalf of calling process. We can't get it with
51  * MessageBuffer.
52  *
53  * This function should be called _ONLY_ in this particular case.
54  *
55  */
56 int sendToServerAncData(char const * const interface, const RawBuffer &send, struct msghdr &hdr);
57
58 /*
59  * Decorator function that performs frequently repeated exception handling in
60  * SS client API functions. Accepts lambda expression as an argument.
61  */
62 int try_catch(const std::function<int()>& func);
63
64 } // namespace SecuritySever
65
66 #endif // _SECURITY_SERVER_CLIENT_