Re-organized sub-directory by category
[staging/basesystem.git] / service / native / framework_unified / client / NS_FrameworkCore / src / frameworkunified_framework_message_center.cpp
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup  tag_NSFramework
19 /// \brief
20 ///
21 ///
22 ///
23 ///////////////////////////////////////////////////////////////////////////////
24 #include <native_service/frameworkunified_framework_if.h>
25 #include <native_service/ns_message_center_if.h>
26 #include <other_service/strlcpy.h>
27 #include "frameworkunified_framework_core.h"
28 #include "ns_mc_internal.h"
29
30 using std::malloc;
31 using std::free;
32 using std::strcpy;
33 using std::strlen;
34 using std::memset;
35
36 extern __thread HANDLE responseWaitQ;
37
38 //////////////////////////////////////////
39 // Function : FrameworkunifiedMcOpenSender
40 //////////////////////////////////////////
41 HANDLE FrameworkunifiedMcOpenSender(HANDLE hApp, PCSTR pName) {
42   MsgQInfo *pMsgQ = NULL;
43
44   if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != pName)) {
45     UI_32 l_ui32SrvNameLen = static_cast<UI_32>(strlen(pName));
46     /**
47      * @todo
48      *  CHAR cSessionName[MAX_QUEUE_NAME_SIZE] cannot be determined to be 20 bytes including the termination NULL.
49      */
50     if ((l_ui32SrvNameLen < MAX_NAME_SIZE_APP) && (l_ui32SrvNameLen > 0)) {
51       CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
52       pMsgQ = reinterpret_cast<MsgQInfo *>(malloc(sizeof(MsgQInfo)));
53
54       if (NULL != pMsgQ) {  // LCOV_EXCL_BR_LINE 5:malloc's error case.
55         errno = EOK;  // flush previous errors, if any.
56         memset(pMsgQ, 0, sizeof(MsgQInfo));
57         if (NULL == (pMsgQ->hMsgQ = McOpenSender(pName))) {
58           FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__,
59                  "Error::errno:%d, hApp:0x%p, %s failed to McOpenSender",
60                  errno, hApp, pName);
61           free(pMsgQ);
62           pMsgQ = NULL;
63         } else {
64           pMsgQ->checkCode = MSGQ_CHECK_CODE;
65           pMsgQ->self = pthread_self();
66           strlcpy(pMsgQ->cSrcName, pApp->cAppName, sizeof(pMsgQ->cSrcName));
67           strlcpy(pMsgQ->cMsgQName, pName, sizeof(pMsgQ->cMsgQName));
68           pMsgQ->sessionId = 0;
69         }
70       }
71     } else {
72       // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
73       FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__,
74              "Invalid param. Name:%s, Following must be true: %d > len of passed name(%u) > 0.",
75              pName, MAX_NAME_SIZE_APP, l_ui32SrvNameLen);
76       // LCOV_EXCL_BR_STOP
77     }
78   } else {
79     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__,
80            "Invalid param. hApp:0x%p, name:0x%p",
81            hApp, pName);  // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
82   }
83
84   return static_cast<HANDLE>(pMsgQ);
85 }
86
87
88 //////////////////////////////////////////
89 // Function : FrameworkunifiedMcClose
90 //////////////////////////////////////////
91 EFrameworkunifiedStatus FrameworkunifiedMcClose(HANDLE hService) {
92   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
93   if (frameworkunifiedCheckValidMsgQ(hService)) {
94     MsgQInfo *pMsgQ    = reinterpret_cast<MsgQInfo *>(hService);
95     pMsgQ->checkCode = 0;
96     if (NULL != pMsgQ->hMsgQ) {
97       eStatus = McClose(pMsgQ->hMsgQ);
98       pMsgQ->hMsgQ = NULL;
99     }
100     free(pMsgQ);
101     pMsgQ = NULL;
102     hService = NULL;  // This has no effect because hService is not passed as reference.
103   } else {
104     eStatus = eFrameworkunifiedStatusInvldHandle;
105   }
106   return eStatus;
107 }
108
109
110 //////////////////////////////////////////
111 // Function : FrameworkunifiedSendMsg
112 //////////////////////////////////////////
113 EFrameworkunifiedStatus FrameworkunifiedSendMsg(HANDLE hService, UI_32 iCmd, UI_32 length, PCVOID data) {
114   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
115   if (frameworkunifiedCheckValidMsgQ(hService)) {
116     MsgQInfo *pMsgQ = reinterpret_cast<MsgQInfo *>(hService);
117
118     if ((NULL != pMsgQ->hMsgQ) && (0 != std::strlen(pMsgQ->cSrcName))) {
119       eStatus = McSendWithSession(pMsgQ->hMsgQ, pMsgQ->cSrcName, iCmd, length, data, pMsgQ->sessionId);
120     } else {
121       eStatus = eFrameworkunifiedStatusInvldHandle;
122     }
123   } else {
124     eStatus = eFrameworkunifiedStatusNullPointer;
125   }
126   // check if McSendWithSession failed with error destination msg queue full
127   // log the information
128   if (eFrameworkunifiedStatusMsgQFull == eStatus) {
129     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error!! Message queue full of receiver '%s' while sending CmdId = 0x%X",
130            FrameworkunifiedGetSessionName(hService), iCmd);
131   }
132
133   return eStatus;
134 }
135
136 //////////////////////////////////////////
137 // Function : FrameworkunifiedSendPriorityMsg
138 //////////////////////////////////////////
139 EFrameworkunifiedStatus FrameworkunifiedSendPriorityMsg(HANDLE hService, UI_32 iCmd, UI_32 length, PCVOID data) {
140   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
141   if (frameworkunifiedCheckValidMsgQ(hService)) {
142     MsgQInfo *pMsgQ    = reinterpret_cast<MsgQInfo *>(hService);
143     eStatus = McSendWithPriority(pMsgQ->hMsgQ, pMsgQ->cSrcName, iCmd,
144       length, data, eFrameworkunifiedMsgPrioEmergency, pMsgQ->sessionId);
145   } else {
146     eStatus = eFrameworkunifiedStatusNullPointer;
147   }
148
149   return eStatus;
150 }
151
152 //////////////////////////////////////////
153 // Function: FrameworkunifiedSendSelf
154 //////////////////////////////////////////
155 EFrameworkunifiedStatus FrameworkunifiedSendSelf(HANDLE hApp, UI_32 iCmd, UI_32 length, PCVOID data) {
156   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
157   if (frameworkunifiedCheckValidAppHandle(hApp)) {
158     CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hApp);
159     eStatus = McSend(pApp->hAppSndMsgQ, &pApp->cAppName[ 0 ], iCmd, length, data);
160   } else {
161     eStatus = eFrameworkunifiedStatusNullPointer;
162   }
163   return eStatus;
164 }
165
166 //////////////////////////////////////////
167 // Function : FrameworkunifiedInvokeSync
168 //////////////////////////////////////////
169 EFrameworkunifiedStatus FrameworkunifiedInvokeSync(HANDLE hService, UI_32 iCmd, UI_32 msgLenght, PCVOID msgData, UI_32 responseLength,
170                          PVOID responseData, UI_32 *receivedLength) {
171   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
172
173   if (frameworkunifiedCheckValidMsgQ(hService)) {
174     if (NULL != receivedLength) {
175       MsgQInfo *pMsgQ = static_cast<MsgQInfo *>(hService);
176
177       if (responseWaitQ == NULL) {
178         char mc_invoker_name[MAX_QUEUE_NAME_SIZE];
179         InvokerName invokerName;
180         // LCOV_EXCL_BR_START 11:except branch
181         McCreateInvokerName(pMsgQ->cSrcName, pMsgQ->sessionId, mc_invoker_name, sizeof(mc_invoker_name));
182         // LCOV_EXCL_BR_STOP
183         invokerName = mc_invoker_name;
184
185         responseWaitQ = McOpenSyncReceiver(invokerName.c_str());
186         if (NULL == responseWaitQ) {
187           eStatus = eFrameworkunifiedStatusFail;
188         }
189       }
190
191       if (eStatus == eFrameworkunifiedStatusOK) {
192         eStatus = McInvokeSync(pMsgQ->hMsgQ, pMsgQ->cSrcName, iCmd, msgLenght, msgData, pMsgQ->sessionId,
193                                responseWaitQ, responseLength, responseData, receivedLength);
194       }
195     } else {
196       eStatus = eFrameworkunifiedStatusInvldParam;
197     }
198   } else {
199     eStatus = eFrameworkunifiedStatusNullPointer;
200   }
201
202   return eStatus;
203 }
204
205 //////////////////////////////////////////
206 // Function : frameworkunifiedSendSyncResponse
207 //////////////////////////////////////////
208 EFrameworkunifiedStatus frameworkunifiedSendSyncResponse(HANDLE hApp, UI_32 iCmd, UI_32 seq_id, EFrameworkunifiedStatus retValue, UI_32 length, PCVOID data) {
209   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
210
211   if (frameworkunifiedCheckValidAppHandle(hApp)) {
212     CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
213     HANDLE responseSendQ;
214
215     char mc_invoker_name[MAX_QUEUE_NAME_SIZE];
216     InvokerName invokerName;
217     PVOID rcv_buf = static_cast<PVOID>(pApp->uiMsgRcvBuffer);
218     McCreateInvokerName(McGetMsgSrc(rcv_buf), mcGetMsgSsessionId(rcv_buf), mc_invoker_name, sizeof(mc_invoker_name));
219     invokerName = mc_invoker_name;
220
221     InvokeResponseQTable::iterator s_iterator = pApp->invokeResQTable.find(invokerName);
222     if (s_iterator != pApp->invokeResQTable.end()) {
223       responseSendQ = s_iterator->second;
224     } else {
225       responseSendQ = McOpenSyncSender(invokerName.c_str());  // LCOV_EXCL_BR_LINE 11:except branch
226       /*
227        * @todo
228        * FrameworkunifiedSendSyncResponse() uses McOpenSyncSender() to create a synchronous communication response queue handle,
229        * but there is no process to release the queue handle after the response.
230        */
231       if (NULL == responseSendQ) {
232         eStatus = eFrameworkunifiedStatusFail;
233       } else {
234         pApp->invokeResQTable[invokerName] = responseSendQ;  // LCOV_EXCL_BR_LINE 11:except branch
235       }
236     }
237
238     if (eStatus == eFrameworkunifiedStatusOK) {
239       eStatus = McSendSyncResponse(responseSendQ, pApp->cAppName, iCmd, seq_id, retValue, length, data);
240     }
241   } else {
242     eStatus = eFrameworkunifiedStatusNullPointer;
243   }
244   return eStatus;
245 }
246
247 //////////////////////////////////////////
248 // Function : FrameworkunifiedDispatchProcess
249 //////////////////////////////////////////
250 EFrameworkunifiedStatus FrameworkunifiedSetSyncResponseData(HANDLE hApp, PVOID data, UI_32 size) {
251   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
252
253   /*
254    * @todo
255    * When the response data is 0 bytes, it can be transmitted as SYNC data.
256    */
257   if (frameworkunifiedCheckValidAppHandle(hApp) && data != NULL) {
258     CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
259     try {
260       pApp->responsedata.set(data, size);  // LCOV_EXCL_BR_LINE 11:except branch
261     }
262     catch(std::bad_alloc) {
263       FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__, "bad_alloc");
264       eStatus = eFrameworkunifiedStatusFail;
265     }
266   } else {
267     eStatus = eFrameworkunifiedStatusNullPointer;
268   }
269
270   return eStatus;  // LCOV_EXCL_BR_LINE 11:except branch
271 }
272
273 //////////////////////////////////////////
274 // Function : FrameworkunifiedGetMsgLength
275 //////////////////////////////////////////
276 UI_32 FrameworkunifiedGetMsgLength(HANDLE hApp) {
277   if (frameworkunifiedCheckValidAppHandle(hApp)) {
278     CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
279     return McGetLength(static_cast<PVOID>(pApp->uiMsgRcvBuffer));
280   }
281   return 0;
282 }
283
284
285 //////////////////////////////////////////
286 // Function : FrameworkunifiedGetMsgProtocol
287 //////////////////////////////////////////
288 UI_32 FrameworkunifiedGetMsgProtocol(HANDLE hApp) {
289   if (frameworkunifiedCheckValidAppHandle(hApp)) {
290     CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
291     return static_cast<UI_32>(pApp->uiProtocolCmd);
292   }
293   return 0;
294 }
295
296
297 //////////////////////////////////////////
298 // Function : FrameworkunifiedGetMsgDataOfSize
299 //////////////////////////////////////////
300 EFrameworkunifiedStatus FrameworkunifiedGetMsgDataOfSize(HANDLE hApp, PVOID pData, UI_32 uiSize, ESMRetrieveTypes eRetrieveMethod) {
301   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
302   CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
303
304   if (frameworkunifiedCheckValidAppHandle(hApp)) {
305     /*
306      * @todo
307      * The behavior is the same as when "eSMRRetain" is set without getting an error when the ESMRetrieveTypes is not appropriate.
308      */
309     if (eSMRRelease == eRetrieveMethod) {
310       eStatus = McGetDataOfSize(static_cast<PVOID>(pApp->uiMsgRcvBuffer), pData, uiSize);
311     } else {
312       eStatus = McGetDataOfSizeWithSMRetain(static_cast<PVOID>(pApp->uiMsgRcvBuffer), pData, uiSize);
313     }
314   } else {
315     eStatus = eFrameworkunifiedStatusNullPointer;
316   }
317
318   return eStatus;
319 }
320
321
322 //////////////////////////////////////////
323 // Function : FrameworkunifiedGetDataPointer
324 //////////////////////////////////////////
325 EFrameworkunifiedStatus FrameworkunifiedGetDataPointer(HANDLE hApp, void **datap) {
326   if (frameworkunifiedCheckValidAppHandle(hApp)) {
327     if (NULL == datap) {
328       return eFrameworkunifiedStatusInvldParam;
329     }
330
331     CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
332     void *dt;
333     if ((dt = McGetDataPointer(reinterpret_cast<PVOID>(pApp->uiMsgRcvBuffer))) == NULL) {
334       return eFrameworkunifiedStatusInvldBufSize;
335     }
336
337     *datap = dt;
338     return eFrameworkunifiedStatusOK;
339   }
340   return eFrameworkunifiedStatusInvldHandle;
341 }
342
343
344 //////////////////////////////////////////
345 // Function : FrameworkunifiedGetMsgSrc
346 //////////////////////////////////////////
347 PCSTR FrameworkunifiedGetMsgSrc(HANDLE hApp) {
348   if (frameworkunifiedCheckValidAppHandle(hApp)) {
349     CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
350     return (reinterpret_cast<PCSTR>(pApp->cMsgSrcName));
351   }
352   return NULL;
353 }
354
355
356 //////////////////////////////////////////
357 // Function : FrameworkunifiedGetMsgNotification
358 //////////////////////////////////////////
359 PCSTR FrameworkunifiedGetMsgNotification(HANDLE hApp) {
360   if (frameworkunifiedCheckValidAppHandle(hApp)) {
361     CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
362     return (reinterpret_cast<PCSTR>(pApp->cSystemInfo));
363   }
364   return NULL;
365 }
366
367
368 //////////////////////////////////////////
369 // Function : FrameworkunifiedClearMsgData
370 //////////////////////////////////////////
371 EFrameworkunifiedStatus FrameworkunifiedClearMsgData(HANDLE hApp) {
372   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
373   if (frameworkunifiedCheckValidAppHandle(hApp)) {
374     CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
375     eStatus = McClearData(static_cast<PVOID>(pApp->uiMsgRcvBuffer));
376   } else {
377     eStatus = eFrameworkunifiedStatusNullPointer;
378   }
379   return eStatus;
380 }
381
382
383 //////////////////////////////////////////
384 // Function : FrameworkunifiedGetDataUSID
385 //////////////////////////////////////////
386 TMemID FrameworkunifiedGetDataUSID(HANDLE hApp) {
387   if (frameworkunifiedCheckValidAppHandle(hApp)) {
388     CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
389     return McGetDataUSID(static_cast<PVOID>(pApp->uiMsgRcvBuffer));
390   }
391   return BAD_MEM_ID;
392 }
393
394
395 //////////////////////////////////////////
396 // Function : FrameworkunifiedForwardMessage
397 //////////////////////////////////////////
398 EFrameworkunifiedStatus FrameworkunifiedForwardMessage(HANDLE hApp, HANDLE hChildQ, UI_32 iCmd) {
399   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldBuf;
400
401   if (frameworkunifiedCheckValidAppHandle(hApp) && hChildQ) {
402     CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hApp);
403
404     eStatus = McForward(hChildQ, &pApp->cAppName[ 0 ], iCmd, FrameworkunifiedGetDataUSID(hApp));
405   } else {
406     eStatus = eFrameworkunifiedStatusInvldHandle;
407   }
408
409   return eStatus;
410 }
411
412
413 //////////////////////////////////////////
414 // Function : FrameworkunifiedGetSystemInfo
415 //////////////////////////////////////////
416 EFrameworkunifiedStatus FrameworkunifiedGetSystemInfo(HANDLE hApp, PVOID pSystemInfo) {
417   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldBuf;
418
419   if (frameworkunifiedCheckValidAppHandle(hApp) && pSystemInfo != NULL) {  // LCOV_EXCL_BR_LINE 11:except branch
420     CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
421
422     eStatus = McGetSysInfoData(pApp->uiMsgRcvBuffer, pSystemInfo);
423 //    memcpy(pSystemInfo, pApp->cSystemInfo, _countof(pApp->cSystemInfo));
424 //    eStatus = eFrameworkunifiedStatusOK;
425   }
426   return eStatus;
427 }
428
429
430 //////////////////////////////////////////
431 // Function : frameworkunifiedGetIsTypeOfSync
432 //////////////////////////////////////////
433 BOOL frameworkunifiedGetIsTypeOfSync(HANDLE hApp) {
434   if (frameworkunifiedCheckValidAppHandle(hApp)) {
435     CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
436     return mcGetIsTypeOfSync(pApp->uiMsgRcvBuffer);
437   }
438   return FALSE;
439 }
440
441
442 ////////////////////////////////////////////////////////////////////////////////////////////
443 /// FrameworkunifiedGetLastNotification
444 /// Returns the last notification string that was received.
445 ///
446 /// \param [in] hApp
447 ///         HANDLE - Application framework handle
448 ///
449 /// \return pSourceName
450 ///         PCSTR - the last notification name that has been received.
451 ///
452 /// \see FrameworkunifiedMcOpenSender, FrameworkunifiedMcClose, FrameworkunifiedSendMsg, FrameworkunifiedGetMsgLength, FrameworkunifiedGetMsgDataOfSize,
453 ///      FrameworkunifiedClearMsgData, FrameworkunifiedGetDataUSID, FrameworkunifiedForwardMessage, FrameworkunifiedGetSystemInfo
454 ///
455 ////////////////////////////////////////////////////////////////////////////////////////////
456 PCSTR FrameworkunifiedGetLastNotification(HANDLE hApp) {
457   if (frameworkunifiedCheckValidAppHandle(hApp)) {
458     CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
459     return static_cast<PCSTR>(pApp->cSystemInfo);
460   }
461
462   return NULL;
463 }
464
465
466 EFrameworkunifiedStatus FrameworkunifiedSendResponse(HANDLE hApp, UI_32 iCmd, UI_32 length, PCVOID data) {
467   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
468   if (frameworkunifiedCheckValidAppHandle(hApp)) {
469     HANDLE hSession = FrameworkunifiedGetCurrentSessionHandle(hApp);
470
471     if (hSession) {
472       // send response
473       if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedSendMsg(hSession, iCmd, length, data))) {
474         // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
475         FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__,
476                "Response send Failed Status:0x%x ", eStatus);
477         // LCOV_EXCL_BR_STOP
478       } else {
479         FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __PRETTY_FUNCTION__, "Response sent ");
480       }
481     }
482   }
483   return eStatus;
484 }
485
486 EFrameworkunifiedStatus FrameworkunifiedSendRequest(HANDLE hApp, PCSTR pServerName, UI_32 uiSessionId, UI_32 iCmd,
487                           UI_32 length, PCVOID data) {
488   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
489   if (frameworkunifiedCheckValidAppHandle(hApp)) {
490     HANDLE hSession = FrameworkunifiedGetSessionHandle(hApp, pServerName, uiSessionId);
491     if (hSession) {
492       // send response
493       if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedSendMsg(hSession, iCmd, length, data))) {
494         FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__,
495                "Response send Failed Status:0x%x ", eStatus);
496       } else {
497         FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __PRETTY_FUNCTION__, "Response sent ");
498       }
499     }
500   }
501   return eStatus;
502 }