Lines Matching refs:reqNode

38 static inline int CheckMsg(const AppSpawnReqMsgNode *reqNode, const AppSpawnTlv *tlv, const char *n…  in CheckMsg()  argument
40 if ((reqNode->msg->msgLen + tlv->tlvLen) > MAX_MSG_TOTAL_LENGTH) { in CheckMsg()
44 if (reqNode->msg->msgType == MSG_GET_RENDER_TERMINATION_STATUS) { in CheckMsg()
62 static AppSpawnMsgBlock *CreateAppSpawnMsgBlock(AppSpawnReqMsgNode *reqNode) in CreateAppSpawnMsgBlock() argument
69 OH_ListAddTail(&reqNode->msgBlocks, &block->node); in CreateAppSpawnMsgBlock()
73 static AppSpawnMsgBlock *GetValidMsgBlock(const AppSpawnReqMsgNode *reqNode, uint32_t realLen) in GetValidMsgBlock() argument
76 struct ListNode *node = reqNode->msgBlocks.next; in GetValidMsgBlock()
77 while (node != &reqNode->msgBlocks) { in GetValidMsgBlock()
87 static AppSpawnMsgBlock *GetTailMsgBlock(const AppSpawnReqMsgNode *reqNode) in GetTailMsgBlock() argument
90 struct ListNode *node = reqNode->msgBlocks.prev; in GetTailMsgBlock()
91 if (node != &reqNode->msgBlocks) { in GetTailMsgBlock()
121 static int AddAppDataToTail(AppSpawnReqMsgNode *reqNode, const uint8_t *data, uint32_t dataLen, int… in AddAppDataToTail() argument
124 AppSpawnMsgBlock *block = GetTailMsgBlock(reqNode); in AddAppDataToTail()
144 block = CreateAppSpawnMsgBlock(reqNode); in AddAppDataToTail()
150 static int AddAppDataEx(AppSpawnReqMsgNode *reqNode, const char *name, const AppSpawnAppData *data) in AddAppDataEx() argument
163 ret = CheckMsg(reqNode, (AppSpawnTlv *)&tlv, name); in AddAppDataEx()
167 name, tlv.tlvLen, data->dataLen, reqNode->msg->msgLen); in AddAppDataEx()
169 AppSpawnMsgBlock *block = GetValidMsgBlock(reqNode, tlv.tlvLen); in AddAppDataEx()
177 ret = AddAppDataToTail(reqNode, (uint8_t *)&tlv, sizeof(tlv), 0); in AddAppDataEx()
179 ret = AddAppDataToTail(reqNode, data->data, data->dataLen, data->dataType); in AddAppDataEx()
182 reqNode->msg->tlvCount++; in AddAppDataEx()
183 reqNode->msg->msgLen += tlv.tlvLen; in AddAppDataEx()
184 …APPSPAWN_LOGV("AddAppDataEx success name '%{public}s' end: %{public}u", name, reqNode->msg->msgLen… in AddAppDataEx()
188 static int AddAppData(AppSpawnReqMsgNode *reqNode, in AddAppData() argument
202 int ret = CheckMsg(reqNode, &tlv, name); in AddAppData()
206 name, tlv.tlvLen, dataLen, reqNode->msg->msgLen); in AddAppData()
208 AppSpawnMsgBlock *block = GetValidMsgBlock(reqNode, tlv.tlvLen); in AddAppData()
219 ret = AddAppDataToTail(reqNode, (uint8_t *)&tlv, sizeof(tlv), 0); in AddAppData()
223 …ret = AddAppDataToTail(reqNode, (uint8_t *)data[index].data, data[index].dataLen, data[index].data… in AddAppData()
227 reqNode->msg->msgLen += tlv.tlvLen; in AddAppData()
228 …APPSPAWN_LOGV("AddAppData success tlvType %{public}s end: %{public}u", name, reqNode->msg->msgLen); in AddAppData()
232 static int SetFlagsTlv(AppSpawnReqMsgNode *reqNode, in SetFlagsTlv() argument
247 reqNode->msg->msgLen += flagsLen; in SetFlagsTlv()
248 reqNode->msg->tlvCount++; in SetFlagsTlv()
252 static int CreateBaseMsg(AppSpawnReqMsgNode *reqNode, uint32_t msgType, const char *processName) in CreateBaseMsg() argument
254 AppSpawnMsgBlock *block = CreateAppSpawnMsgBlock(reqNode); in CreateBaseMsg()
258 reqNode->msg = (AppSpawnMsg *)(block->buffer + block->currentIndex); in CreateBaseMsg()
259 reqNode->msg->magic = APPSPAWN_MSG_MAGIC; in CreateBaseMsg()
260 reqNode->msg->msgId = 0; in CreateBaseMsg()
261 reqNode->msg->msgType = msgType; in CreateBaseMsg()
262 reqNode->msg->msgLen = sizeof(AppSpawnMsg); in CreateBaseMsg()
263 reqNode->msg->tlvCount = 0; in CreateBaseMsg()
264 int ret = strcpy_s(reqNode->msg->processName, sizeof(reqNode->msg->processName), processName); in CreateBaseMsg()
267 ret = SetFlagsTlv(reqNode, block, &reqNode->msgFlags, TLV_MSG_FLAGS, MAX_FLAGS_INDEX); in CreateBaseMsg()
272 ret = SetFlagsTlv(reqNode, block, &reqNode->permissionFlags, TLV_PERMISSION, maxCount); in CreateBaseMsg()
274 …APPSPAWN_LOGV("CreateBaseMsg msgLen: %{public}u %{public}u", reqNode->msg->msgLen, block->currentI… in CreateBaseMsg()
278 static void DeleteAppSpawnReqMsg(AppSpawnReqMsgNode *reqNode) in DeleteAppSpawnReqMsg() argument
280 APPSPAWN_CHECK_ONLY_EXPER(reqNode != NULL, return); in DeleteAppSpawnReqMsg()
281 APPSPAWN_LOGV("DeleteAppSpawnReqMsg reqId: %{public}u", reqNode->reqId); in DeleteAppSpawnReqMsg()
282 reqNode->msgFlags = NULL; in DeleteAppSpawnReqMsg()
283 reqNode->permissionFlags = NULL; in DeleteAppSpawnReqMsg()
284 reqNode->msg = NULL; in DeleteAppSpawnReqMsg()
286 OH_ListRemoveAll(&reqNode->msgBlocks, FreeMsgBlock); in DeleteAppSpawnReqMsg()
287 free(reqNode); in DeleteAppSpawnReqMsg()
293 AppSpawnReqMsgNode *reqNode = (AppSpawnReqMsgNode *)malloc(sizeof(AppSpawnReqMsgNode)); in CreateAppSpawnReqMsg() local
294 …APPSPAWN_CHECK(reqNode != NULL, return NULL, "Failed to create msg node for %{public}s", processNa… in CreateAppSpawnReqMsg()
296 OH_ListInit(&reqNode->node); in CreateAppSpawnReqMsg()
297 OH_ListInit(&reqNode->msgBlocks); in CreateAppSpawnReqMsg()
298 reqNode->reqId = ++reqId; in CreateAppSpawnReqMsg()
299 reqNode->msg = NULL; in CreateAppSpawnReqMsg()
300 reqNode->msgFlags = NULL; in CreateAppSpawnReqMsg()
301 reqNode->permissionFlags = NULL; in CreateAppSpawnReqMsg()
302 reqNode->fdCount = 0; in CreateAppSpawnReqMsg()
303 reqNode->isAsan = 0; in CreateAppSpawnReqMsg()
304 int ret = CreateBaseMsg(reqNode, msgType, processName); in CreateAppSpawnReqMsg()
305 APPSPAWN_CHECK(ret == 0, DeleteAppSpawnReqMsg(reqNode); in CreateAppSpawnReqMsg()
308 reqNode->reqId, msgType, processName); in CreateAppSpawnReqMsg()
309 return reqNode; in CreateAppSpawnReqMsg()
315 AppSpawnReqMsgNode *reqNode = (AppSpawnReqMsgNode *)reqHandle; in AppSpawnReqMsgAddFd() local
316 APPSPAWN_CHECK(reqNode != NULL, return APPSPAWN_ARG_INVALID, "Invalid reqNode"); in AppSpawnReqMsgAddFd()
318 && reqNode->fdCount < APP_MAX_FD_COUNT, return APPSPAWN_ARG_INVALID, in AppSpawnReqMsgAddFd()
319 "Invalid fdinfo %{public}d %{public}d %{public}d", fd, fdName != NULL, reqNode->fdCount); in AppSpawnReqMsgAddFd()
320 reqNode->fds[reqNode->fdCount++] = fd; in AppSpawnReqMsgAddFd()
349 AppSpawnReqMsgNode *reqNode = CreateAppSpawnReqMsg(msgType, processName); in AppSpawnReqMsgCreate() local
350 APPSPAWN_CHECK(reqNode != NULL, return APPSPAWN_SYSTEM_ERROR, in AppSpawnReqMsgCreate()
352 *reqHandle = (AppSpawnReqMsgHandle)(reqNode); in AppSpawnReqMsgCreate()
358 AppSpawnReqMsgNode *reqNode = (AppSpawnReqMsgNode *)reqHandle; in AppSpawnReqMsgFree() local
359 APPSPAWN_CHECK_ONLY_EXPER(reqNode != NULL, return); in AppSpawnReqMsgFree()
360 DeleteAppSpawnReqMsg(reqNode); in AppSpawnReqMsgFree()
365 AppSpawnReqMsgNode *reqNode = (AppSpawnReqMsgNode *)reqHandle; in AppSpawnReqMsgSetAppDacInfo() local
366 APPSPAWN_CHECK_ONLY_EXPER(reqNode != NULL, return APPSPAWN_ARG_INVALID); in AppSpawnReqMsgSetAppDacInfo()
371 GetSpecialGid(reqNode->msg->processName, tmpDacInfo.gidTable, &tmpDacInfo.gidCount); in AppSpawnReqMsgSetAppDacInfo()
376 return AddAppData(reqNode, TLV_DAC_INFO, data, 1, "TLV_DAC_INFO"); in AppSpawnReqMsgSetAppDacInfo()
381 AppSpawnReqMsgNode *reqNode = (AppSpawnReqMsgNode *)reqHandle; in AppSpawnReqMsgSetBundleInfo() local
382 APPSPAWN_CHECK_ONLY_EXPER(reqNode != NULL, return APPSPAWN_ARG_INVALID); in AppSpawnReqMsgSetBundleInfo()
394 return AddAppData(reqNode, TLV_BUNDLE_INFO, data, MAX_DATA_IN_TLV, "TLV_BUNDLE_INFO"); in AppSpawnReqMsgSetBundleInfo()
408 AppSpawnReqMsgNode *reqNode = (AppSpawnReqMsgNode *)reqHandle; in AppSpawnReqMsgSetAppFlag() local
409 APPSPAWN_CHECK_ONLY_EXPER(reqNode != NULL, return APPSPAWN_ARG_INVALID); in AppSpawnReqMsgSetAppFlag()
410 APPSPAWN_CHECK(reqNode->msgFlags != NULL, return APPSPAWN_ARG_INVALID, "No msg flags tlv "); in AppSpawnReqMsgSetAppFlag()
413 if (!reqNode->isAsan && in AppSpawnReqMsgSetAppFlag()
417 reqNode->isAsan = 1; in AppSpawnReqMsgSetAppFlag()
420 return SetAppSpawnMsgFlags(reqNode->msgFlags, flagIndex); in AppSpawnReqMsgSetAppFlag()
425 AppSpawnReqMsgNode *reqNode = (AppSpawnReqMsgNode *)reqHandle; in AppSpawnReqMsgAddExtInfo() local
426 APPSPAWN_CHECK_ONLY_EXPER(reqNode != NULL, return APPSPAWN_ARG_INVALID); in AppSpawnReqMsgAddExtInfo()
436 return AddAppDataEx(reqNode, name, data); // 2 max count in AppSpawnReqMsgAddExtInfo()
441 AppSpawnReqMsgNode *reqNode = (AppSpawnReqMsgNode *)reqHandle; in AppSpawnReqMsgAddStringInfo() local
442 APPSPAWN_CHECK_ONLY_EXPER(reqNode != NULL, return APPSPAWN_ARG_INVALID); in AppSpawnReqMsgAddStringInfo()
453 return AddAppDataEx(reqNode, name, data); // 2 max count in AppSpawnReqMsgAddStringInfo()
458 AppSpawnReqMsgNode *reqNode = (AppSpawnReqMsgNode *)reqHandle; in AppSpawnReqMsgAddPermission() local
459 APPSPAWN_CHECK_ONLY_EXPER(reqNode != NULL, return APPSPAWN_ARG_INVALID); in AppSpawnReqMsgAddPermission()
461 …APPSPAWN_CHECK(reqNode->permissionFlags != NULL, return APPSPAWN_ARG_INVALID, "No permission tlv "… in AppSpawnReqMsgAddPermission()
468 int ret = SetAppSpawnMsgFlags(reqNode->permissionFlags, index); in AppSpawnReqMsgAddPermission()
475 AppSpawnReqMsgNode *reqNode = (AppSpawnReqMsgNode *)reqHandle; in AppSpawnReqMsgSetAppDomainInfo() local
476 APPSPAWN_CHECK_ONLY_EXPER(reqNode != NULL, return APPSPAWN_ARG_INVALID); in AppSpawnReqMsgSetAppDomainInfo()
488 return AddAppData(reqNode, TLV_DOMAIN_INFO, data, MAX_DATA_IN_TLV, "TLV_DOMAIN_INFO"); in AppSpawnReqMsgSetAppDomainInfo()
493 AppSpawnReqMsgNode *reqNode = (AppSpawnReqMsgNode *)reqHandle; in AppSpawnReqMsgSetAppInternetPermissionInfo() local
494 APPSPAWN_CHECK_ONLY_EXPER(reqNode != NULL, return APPSPAWN_ARG_INVALID); in AppSpawnReqMsgSetAppInternetPermissionInfo()
502 return AddAppData(reqNode, TLV_INTERNET_INFO, data, 1, "TLV_INTERNET_INFO"); in AppSpawnReqMsgSetAppInternetPermissionInfo()
507 AppSpawnReqMsgNode *reqNode = (AppSpawnReqMsgNode *)reqHandle; in AppSpawnReqMsgSetAppOwnerId() local
508 APPSPAWN_CHECK_ONLY_EXPER(reqNode != NULL, return APPSPAWN_ARG_INVALID); in AppSpawnReqMsgSetAppOwnerId()
516 return AddAppData(reqNode, TLV_OWNER_INFO, data, 1, "TLV_OWNER_INFO"); in AppSpawnReqMsgSetAppOwnerId()
521 AppSpawnReqMsgNode *reqNode = (AppSpawnReqMsgNode *)reqHandle; in AppSpawnReqMsgSetAppAccessToken() local
522 APPSPAWN_CHECK_ONLY_EXPER(reqNode != NULL, return APPSPAWN_ARG_INVALID); in AppSpawnReqMsgSetAppAccessToken()
527 return AddAppData(reqNode, TLV_ACCESS_TOKEN_INFO, data, 1, "TLV_ACCESS_TOKEN_INFO"); in AppSpawnReqMsgSetAppAccessToken()
533 …AppSpawnReqMsgNode *reqNode = CreateAppSpawnReqMsg(MSG_GET_RENDER_TERMINATION_STATUS, "terminate-p… in AppSpawnTerminateMsgCreate() local
534 APPSPAWN_CHECK(reqNode != NULL, return APPSPAWN_SYSTEM_ERROR, "Failed to create msg node"); in AppSpawnTerminateMsgCreate()
539 …int ret = AddAppData(reqNode, TLV_RENDER_TERMINATION_INFO, data, 1, "TLV_RENDER_TERMINATION_INFO"); in AppSpawnTerminateMsgCreate()
540 APPSPAWN_CHECK_ONLY_EXPER(ret == 0, DeleteAppSpawnReqMsg(reqNode); in AppSpawnTerminateMsgCreate()
542 *reqHandle = (AppSpawnReqMsgHandle)(reqNode); in AppSpawnTerminateMsgCreate()
550 AppSpawnReqMsgNode *reqNode = (AppSpawnReqMsgNode *)reqHandle; in AppSpawnClientAddPermission() local
551 APPSPAWN_CHECK_ONLY_EXPER(reqNode != NULL, return APPSPAWN_ARG_INVALID); in AppSpawnClientAddPermission()
553 …APPSPAWN_CHECK(reqNode->permissionFlags != NULL, return APPSPAWN_ARG_INVALID, "No permission tlv "… in AppSpawnClientAddPermission()
560 int ret = SetAppSpawnMsgFlags(reqNode->permissionFlags, index); in AppSpawnClientAddPermission()