Lines Matching refs:message
27 void *GetAppSpawnMsgInfo(const AppSpawnMsgNode *message, int type) in GetAppSpawnMsgInfo() argument
30 APPSPAWN_CHECK_ONLY_EXPER(message != NULL && message->buffer != NULL, return NULL); in GetAppSpawnMsgInfo()
31 APPSPAWN_CHECK_ONLY_EXPER(message->tlvOffset != NULL, return NULL); in GetAppSpawnMsgInfo()
32 APPSPAWN_CHECK_ONLY_EXPER(message->tlvOffset[type] != INVALID_OFFSET, return NULL); in GetAppSpawnMsgInfo()
33 return (void *)(message->buffer + message->tlvOffset[type] + sizeof(AppSpawnTlv)); in GetAppSpawnMsgInfo()
36 void *GetAppSpawnMsgExtInfo(const AppSpawnMsgNode *message, const char *name, uint32_t *len) in GetAppSpawnMsgExtInfo() argument
39 APPSPAWN_CHECK_ONLY_EXPER(message != NULL && message->buffer != NULL, return NULL); in GetAppSpawnMsgExtInfo()
40 APPSPAWN_CHECK_ONLY_EXPER(message->tlvOffset != NULL, return NULL); in GetAppSpawnMsgExtInfo()
42 …APPSPAWN_LOGV("GetAppSpawnMsgExtInfo tlvCount %{public}d name %{public}s", message->tlvCount, name… in GetAppSpawnMsgExtInfo()
43 for (uint32_t index = TLV_MAX; index < (TLV_MAX + message->tlvCount); index++) { in GetAppSpawnMsgExtInfo()
44 if (message->tlvOffset[index] == INVALID_OFFSET) { in GetAppSpawnMsgExtInfo()
47 uint8_t *data = message->buffer + message->tlvOffset[index]; in GetAppSpawnMsgExtInfo()
63 int CheckAppSpawnMsgFlag(const AppSpawnMsgNode *message, uint32_t type, uint32_t index) in CheckAppSpawnMsgFlag() argument
66 AppSpawnMsgFlags *msgFlags = (AppSpawnMsgFlags *)GetAppSpawnMsgInfo(message, type); in CheckAppSpawnMsgFlag()
85 int SetAppSpawnMsgFlag(const AppSpawnMsgNode *message, uint32_t type, uint32_t index) in SetAppSpawnMsgFlag() argument
89 AppSpawnMsgFlags *msgFlags = (AppSpawnMsgFlags *)GetAppSpawnMsgInfo(message, type); in SetAppSpawnMsgFlag()
96 AppSpawnMsgNode *message = (AppSpawnMsgNode *)calloc(1, sizeof(AppSpawnMsgNode)); in CreateAppSpawnMsg() local
97 APPSPAWN_CHECK(message != NULL, return NULL, "Failed to create message"); in CreateAppSpawnMsg()
98 message->buffer = NULL; in CreateAppSpawnMsg()
99 message->tlvOffset = NULL; in CreateAppSpawnMsg()
100 return message; in CreateAppSpawnMsg()
131 static int AppSpawnMsgRebuild(AppSpawnMsgNode *message, const AppSpawnMsg *msg) in AppSpawnMsgRebuild() argument
133 APPSPAWN_CHECK_ONLY_EXPER(CheckRecvMsg(&message->msgHeader) == 0, return APPSPAWN_MSG_INVALID); in AppSpawnMsgRebuild()
134 if (msg->msgLen == sizeof(message->msgHeader)) { // only has msg header in AppSpawnMsgRebuild()
137 if (message->buffer == NULL) { in AppSpawnMsgRebuild()
138 message->buffer = calloc(1, msg->msgLen - sizeof(message->msgHeader)); in AppSpawnMsgRebuild()
139 … APPSPAWN_CHECK(message->buffer != NULL, return -1, "Failed to alloc memory for recv message"); in AppSpawnMsgRebuild()
141 if (message->tlvOffset == NULL) { in AppSpawnMsgRebuild()
143 message->tlvOffset = malloc(totalCount * sizeof(uint32_t)); in AppSpawnMsgRebuild()
144 … APPSPAWN_CHECK(message->tlvOffset != NULL, return -1, "Failed to alloc memory for recv message"); in AppSpawnMsgRebuild()
146 message->tlvOffset[i] = INVALID_OFFSET; in AppSpawnMsgRebuild()
152 AppSpawnMsgNode *RebuildAppSpawnMsgNode(AppSpawnMsgNode *message, AppSpawnedProcess *appInfo) in RebuildAppSpawnMsgNode() argument
155 APPSPAWN_CHECK(message != NULL && appInfo != NULL, return NULL, "params is null"); in RebuildAppSpawnMsgNode()
159 …int ret = memcpy_s(&node->msgHeader, sizeof(AppSpawnMsg), &message->msgHeader, sizeof(AppSpawnMsg)… in RebuildAppSpawnMsgNode()
161 … bufferLen = message->msgHeader.msgLen + appInfo->message->msgHeader.msgLen - sizeof(AppSpawnMsg); in RebuildAppSpawnMsgNode()
164 node->msgHeader.tlvCount += message->msgHeader.tlvCount; in RebuildAppSpawnMsgNode()
167 uint32_t appInfoBufLen = appInfo->message->msgHeader.msgLen - sizeof(AppSpawnMsg); in RebuildAppSpawnMsgNode()
168 uint32_t msgBufLen = message->msgHeader.msgLen - sizeof(AppSpawnMsg); in RebuildAppSpawnMsgNode()
169 ret = memcpy_s(node->buffer, bufferLen, appInfo->message->buffer, appInfoBufLen); in RebuildAppSpawnMsgNode()
171 …ret = memcpy_s(node->buffer + appInfoBufLen, bufferLen - appInfoBufLen, message->buffer, msgBufLen… in RebuildAppSpawnMsgNode()
178 int CheckAppSpawnMsg(const AppSpawnMsgNode *message) in CheckAppSpawnMsg() argument
180 APPSPAWN_CHECK_ONLY_EXPER(message != NULL, return APPSPAWN_MSG_INVALID); in CheckAppSpawnMsg()
181 APPSPAWN_CHECK(strlen(message->msgHeader.processName) > 0, in CheckAppSpawnMsg()
182 …return APPSPAWN_MSG_INVALID, "Invalid property processName %{public}s", message->msgHeader.process… in CheckAppSpawnMsg()
183 APPSPAWN_CHECK(message->tlvOffset != NULL, in CheckAppSpawnMsg()
184 …return APPSPAWN_MSG_INVALID, "Invalid property tlv offset for %{public}s", message->msgHeader.proc… in CheckAppSpawnMsg()
185 APPSPAWN_CHECK(message->buffer != NULL, in CheckAppSpawnMsg()
186 …return APPSPAWN_MSG_INVALID, "Invalid property buffer for %{public}s", message->msgHeader.processN… in CheckAppSpawnMsg()
188 if (message->tlvOffset[TLV_BUNDLE_INFO] == INVALID_OFFSET || in CheckAppSpawnMsg()
189 message->tlvOffset[TLV_MSG_FLAGS] == INVALID_OFFSET || in CheckAppSpawnMsg()
190 message->tlvOffset[TLV_ACCESS_TOKEN_INFO] == INVALID_OFFSET || in CheckAppSpawnMsg()
191 message->tlvOffset[TLV_DOMAIN_INFO] == INVALID_OFFSET || in CheckAppSpawnMsg()
192 message->tlvOffset[TLV_DAC_INFO] == INVALID_OFFSET) { in CheckAppSpawnMsg()
194 message->tlvOffset[TLV_BUNDLE_INFO], message->tlvOffset[TLV_MSG_FLAGS], in CheckAppSpawnMsg()
195 message->tlvOffset[TLV_ACCESS_TOKEN_INFO], in CheckAppSpawnMsg()
196 message->tlvOffset[TLV_DOMAIN_INFO], message->tlvOffset[TLV_DAC_INFO]); in CheckAppSpawnMsg()
199 …AppSpawnMsgBundleInfo *bundleInfo = (AppSpawnMsgBundleInfo *)GetAppSpawnMsgInfo(message, TLV_BUNDL… in CheckAppSpawnMsg()
257 int DecodeAppSpawnMsg(AppSpawnMsgNode *message) in DecodeAppSpawnMsg() argument
259 APPSPAWN_CHECK_ONLY_EXPER(message != NULL, return APPSPAWN_MSG_INVALID); in DecodeAppSpawnMsg()
262 uint32_t bufferLen = message->msgHeader.msgLen - sizeof(AppSpawnMsg); in DecodeAppSpawnMsg()
265 AppSpawnTlv *tlv = (AppSpawnTlv *)(message->buffer + currLen); in DecodeAppSpawnMsg()
279 message->tlvOffset[tlv->tlvType] = currLen; in DecodeAppSpawnMsg()
282 APPSPAWN_CHECK(tlvCount < message->msgHeader.tlvCount, break, in DecodeAppSpawnMsg()
284 message->tlvOffset[TLV_MAX + tlvCount] = currLen; in DecodeAppSpawnMsg()
291 message->tlvCount = tlvCount; in DecodeAppSpawnMsg()
301 AppSpawnMsgNode *message = *outMsg; in GetAppSpawnMsgFromBuffer() local
302 if (message == NULL) { in GetAppSpawnMsgFromBuffer()
303 message = CreateAppSpawnMsg(); in GetAppSpawnMsgFromBuffer()
304 APPSPAWN_CHECK(message != NULL, return APPSPAWN_SYSTEM_ERROR, "Failed to create message"); in GetAppSpawnMsgFromBuffer()
305 *outMsg = message; in GetAppSpawnMsgFromBuffer()
312 int ret = memcpy_s(((uint8_t *)&message->msgHeader) + *msgRecvLen, in GetAppSpawnMsgFromBuffer()
313 sizeof(message->msgHeader) - *msgRecvLen, in GetAppSpawnMsgFromBuffer()
314 buffer, sizeof(message->msgHeader) - *msgRecvLen); in GetAppSpawnMsgFromBuffer()
317 ret = AppSpawnMsgRebuild(message, &message->msgHeader); in GetAppSpawnMsgFromBuffer()
319 reminderLen = bufferLen - (sizeof(message->msgHeader) - *msgRecvLen); in GetAppSpawnMsgFromBuffer()
320 reminderBuffer = buffer + sizeof(message->msgHeader) - *msgRecvLen; in GetAppSpawnMsgFromBuffer()
321 *msgRecvLen = sizeof(message->msgHeader); in GetAppSpawnMsgFromBuffer()
323 int ret = memcpy_s(((uint8_t *)&message->msgHeader) + *msgRecvLen, in GetAppSpawnMsgFromBuffer()
324 sizeof(message->msgHeader) - *msgRecvLen, buffer, bufferLen); in GetAppSpawnMsgFromBuffer()
331 uint32_t realCopy = (reminderLen + *msgRecvLen) > message->msgHeader.msgLen ? in GetAppSpawnMsgFromBuffer()
332 message->msgHeader.msgLen - *msgRecvLen : reminderLen; in GetAppSpawnMsgFromBuffer()
333 if (message->buffer == NULL) { // only has msg header in GetAppSpawnMsgFromBuffer()
338 int ret = memcpy_s(message->buffer + *msgRecvLen - sizeof(message->msgHeader), in GetAppSpawnMsgFromBuffer()
339 message->msgHeader.msgLen - *msgRecvLen, reminderBuffer, realCopy); in GetAppSpawnMsgFromBuffer()
371 void DumpAppSpawnMsg(const AppSpawnMsgNode *message) in DumpAppSpawnMsg() argument
373 APPSPAWN_CHECK_ONLY_EXPER(message != NULL, return); in DumpAppSpawnMsg()
375 …message->msgHeader.msgId, message->msgHeader.msgLen, message->tlvCount, message->msgHeader.process… in DumpAppSpawnMsg()
377 AppSpawnMsgFlags *msgFlags = (AppSpawnMsgFlags *)GetAppSpawnMsgInfo(message, TLV_MSG_FLAGS); in DumpAppSpawnMsg()
378 …APPSPAWN_ONLY_EXPER(msgFlags != NULL, DumpMsgFlags(message->msgHeader.processName, "App flags", ms… in DumpAppSpawnMsg()
379 msgFlags = (AppSpawnMsgFlags *)GetAppSpawnMsgInfo(message, TLV_PERMISSION); in DumpAppSpawnMsg()
381 DumpMsgFlags(message->msgHeader.processName, "App permission bits", msgFlags)); in DumpAppSpawnMsg()
383 AppSpawnMsgDacInfo *dacInfo = (AppSpawnMsgDacInfo *)GetAppSpawnMsgInfo(message, TLV_DAC_INFO); in DumpAppSpawnMsg()
391 …AppSpawnMsgBundleInfo *bundleInfo = (AppSpawnMsgBundleInfo *)GetAppSpawnMsgInfo(message, TLV_BUNDL… in DumpAppSpawnMsg()
396 …AppSpawnMsgDomainInfo *domainInfo = (AppSpawnMsgDomainInfo *)GetAppSpawnMsgInfo(message, TLV_DOMAI… in DumpAppSpawnMsg()
405 AppSpawnMsgOwnerId *owner = (AppSpawnMsgOwnerId *)GetAppSpawnMsgInfo(message, TLV_OWNER_INFO); in DumpAppSpawnMsg()
408 …AppSpawnMsgInternetInfo *info = (AppSpawnMsgInternetInfo *)GetAppSpawnMsgInfo(message, TLV_INTERNE… in DumpAppSpawnMsg()
413 for (uint32_t i = TLV_MAX; i < TLV_MAX + message->tlvCount; i++) { in DumpAppSpawnMsg()
414 if (message->tlvOffset[i] == INVALID_OFFSET) { in DumpAppSpawnMsg()
417 DumpMsgExtInfo((AppSpawnTlv *)(message->buffer + message->tlvOffset[i])); in DumpAppSpawnMsg()