2 Copyright (c) 2014, McAfee, Inc.
6 Redistribution and use in source and binary forms, with or without modification,
7 are permitted provided that the following conditions are met:
9 Redistributions of source code must retain the above copyright notice, this list
10 of conditions and the following disclaimer.
12 Redistributions in binary form must reproduce the above copyright notice, this
13 list of conditions and the following disclaimer in the documentation and/or other
14 materials provided with the distribution.
16 Neither the name of McAfee, Inc. nor the names of its contributors may be used
17 to endorse or promote products derived from this software without specific prior
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
24 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
28 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29 OF THE POSSIBILITY OF SUCH DAMAGE.
41 * \brief Ipc Server Header File
43 * This file provides the IPC Server API functions used by Security framework.
46 #include <dbus/dbus.h>
48 #include "IpcMacros.h"
51 /*==================================================================================================
52 STRUCTURES AND OTHER TYPEDEFS
53 ==================================================================================================*/
56 * Pointer to method requested by client module.
58 /*typedef int (*CALLBACKFUNC) (void *pHandle, TSC_METHOD_REASON_CODE iReason, void *user_data);*/
59 typedef int (*CALLBACKFUNC) (void *pHandle, int iReason, void *reason_params);
61 typedef int (*METHODFUNC) (void *pData, int argc, char **argv, char ***szReply, int *len, CALLBACKFUNC callback, void *pHandle);
64 * Server side method to handle request from client module. All the requests
65 * are managed in a list.
67 typedef struct _IpcServerMethod
69 char szMethod[TSC_METHOD_NAME_LEN];
71 void *pData; //when execute the method, the pData besides the data passed from client, also has methodHandle for this method
74 #define TSC_NULL ((void *) 0)
76 #define TSCSERVERHANDLE(n) struct n##_struct {int iDummy;}; typedef struct n##_struct *n
77 TSCSERVERHANDLE(TSC_SERVER_HANDLE);
79 #define TSCMETHODHANDLE(n) struct n##_struct {int iDummy;}; typedef struct n##_struct *n
80 TSCMETHODHANDLE(TSC_METHOD_HANDLE);
82 #define INVALID_TSC_METHOD_HANDLE ((TSC_METHOD_HANDLE) TSC_NULL)
84 #define INVALID_TSC_SERVER_HANDLE ((TSC_SERVER_HANDLE) TSC_NULL)
86 /*==================================================================================================
88 ==================================================================================================*/
91 * \brief Adds a handler method to the list of methods at server, to process
92 * request from the client.
94 * During initialisation, the server builds a list of handlers to process
95 * request coming from client-side IPC. Later the client side IPC sends request
96 * along with the name of the handler to use. The handlers are implemented
97 * in the module hosting the server-side IPC.
99 * This is a synchronous API.
101 * \param[in] pMethod Details of the handler method to be added at server-side.
103 * \return Return Type (void) \n
106 int IpcServerAddMethod(TSC_SERVER_HANDLE hServer, IpcServerMethod *pMethod);
109 * \brief Removes a handler method from the list of methods at server.
111 * During initialisation, the server builds a list of handlers to process
112 * request coming from client-side IPC. Later the client side IPC sends request
113 * along with the name of the handler to use. The handlers are implemented
114 * in the module hosting the server-side IPC. As part of un-initialisation
115 * the handler should be removed from the list.
117 * This is a synchronous API.
119 * \param[in] pMethod Pointer to handler method to be removed.
121 * \return Return Type (void) \n
124 int IpcServerRemoveMethod(TSC_SERVER_HANDLE hServer, METHODFUNC pMethod);
128 void IpcCancelMethod(TSC_SERVER_HANDLE hServer, char *method_unique_id);
129 char *IpcGetProgressMethod(TSC_SERVER_HANDLE hServer, char *method_unique_id);
132 * \brief Initialises the server-side IPC to make it ready for request from
135 * The IPC has two parts - client and server. The server-side IPC processes the
136 * request sent from the client-side IPC. The server-side uses handlers provided
137 * by the hosting module. When server comes up, the IPC needs to be initialised
138 * and be ready for the requests.
140 * This is a synchronous API.
142 * \return Return Type (int) \n
143 * 0 - on send success. \n
144 * -1 - on send failure. \n
146 TSC_SERVER_HANDLE IpcServerOpen(char *servie_name);
149 * \brief Close the server-side IPC and release the resources.
151 * This is a synchronous API.
153 * \return Return Type (void) \n
155 void IpcServerClose(TSC_SERVER_HANDLE*);
157 int IpcServerMainLoop(TSC_SERVER_HANDLE hServer);
160 * Callback function for Server Stub in cancel the method, update method progress
169 #endif /* IPCSERVER_H */