openharmony 鸿蒙 capi-ipc-cskeleton-h

2026-08-25 浏览 (1)

ipc_cskeleton.h

Overview

Provides C APIs for managing the token IDs, credentials, process IDs (PIDs), user IDs (UIDs), and thread pool in the IPC framework.

File to include: <IPCKit/ipc_cskeleton.h>

Library: libipc_capi.so

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Related module: OHIPCSkeleton

Summary

Function

NameDescription
void OH_IPCSkeleton_JoinWorkThread(void)Joints this thread to the IPC worker thread pool.
void OH_IPCSkeleton_StopWorkThread(void)Stops this thread.
uint64_t OH_IPCSkeleton_GetCallingTokenId(void)Obtains the token ID of the caller. This function must be called in the IPC context. Otherwise, the local token ID is returned.
uint64_t OH_IPCSkeleton_GetFirstTokenId(void)Obtains the token ID of the first caller.
uint64_t OH_IPCSkeleton_GetSelfTokenId(void)Obtains the local token ID.
uint64_t OH_IPCSkeleton_GetCallingPid(void)Obtains the PID of the caller. This function must be called in the IPC context. Otherwise, the local PID is returned.
uint64_t OH_IPCSkeleton_GetCallingUid(void)Obtains the UID of the caller. This function must be called in the IPC context. Otherwise, the local UID is returned.
int OH_IPCSkeleton_IsLocalCalling(void)Checks whether a local calling is being made.
int OH_IPCSkeleton_SetMaxWorkThreadNum(const int maxThreadNum)Sets the maximum number of worker threads.
int OH_IPCSkeleton_ResetCallingIdentity(char **identity, int32_t *len, OH_IPC_MemAllocator allocator)Resets the caller identity credential (including the token ID, UID, and PID) to that of this process and returns the caller credential information. The credential information is used in OH_IPCSkeleton_SetCallingIdentity.
int OH_IPCSkeleton_SetCallingIdentity(const char *identity)Sets the caller credential information to the IPC context.
int OH_IPCSkeleton_IsHandlingTransaction(void)Checks whether an IPC request is being handled.

Function Description

OH_IPCSkeleton_JoinWorkThread()

void OH_IPCSkeleton_JoinWorkThread(void)

Description

Joints this thread to the IPC worker thread pool.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

OH_IPCSkeleton_StopWorkThread()

void OH_IPCSkeleton_StopWorkThread(void)

Description

Stops this thread.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

OH_IPCSkeleton_GetCallingTokenId()

uint64_t OH_IPCSkeleton_GetCallingTokenId(void)

Description

Obtains the token ID of the caller. This function must be called in the IPC context. Otherwise, the local token ID is returned.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Returns

TypeDescription
uint64_tReturns the caller token ID.

OH_IPCSkeleton_GetFirstTokenId()

uint64_t OH_IPCSkeleton_GetFirstTokenId(void)

Description

Obtains the token ID of the first caller.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Returns

TypeDescription
uint64_tReturns the token ID of the first caller.

OH_IPCSkeleton_GetSelfTokenId()

uint64_t OH_IPCSkeleton_GetSelfTokenId(void)

Description

Obtains the local token ID.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Returns

TypeDescription
uint64_tReturns the local token ID.

OH_IPCSkeleton_GetCallingPid()

uint64_t OH_IPCSkeleton_GetCallingPid(void)

Description

Obtains the PID of the caller. This function must be called in the IPC context. Otherwise, the local PID is returned.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Returns

TypeDescription
uint64_tReturns the caller PID.

OH_IPCSkeleton_GetCallingUid()

uint64_t OH_IPCSkeleton_GetCallingUid(void)

Description

Obtains the UID of the caller. This function must be called in the IPC context. Otherwise, the local UID is returned.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Returns

TypeDescription
uint64_tReturns the caller UID.

OH_IPCSkeleton_IsLocalCalling()

int OH_IPCSkeleton_IsLocalCalling(void)

Description

Checks whether a local calling is being made.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Returns

TypeDescription
intReturns 1 if a local calling is in progress; returns 0 otherwise.

OH_IPCSkeleton_SetMaxWorkThreadNum()

int OH_IPCSkeleton_SetMaxWorkThreadNum(const int maxThreadNum)

Description

Sets the maximum number of worker threads.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
const int maxThreadNumMaximum number of worker threads.
Value range: [1, 32]
Default value: 16

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if the parameters are incorrect.
Returns OH_IPC_ErrorCode#OH_IPC_INNER_ERROR in other cases.

OH_IPCSkeleton_ResetCallingIdentity()

int OH_IPCSkeleton_ResetCallingIdentity(char **identity, int32_t *len, OH_IPC_MemAllocator allocator)

Description

Resets the caller identity credential (including the token ID, UID, and PID) to that of this process and returns the caller credential information. The credential information is used in OH_IPCSkeleton_SetCallingIdentity.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
char **identityDouble pointer to the address of the memory for holding the caller identity information. The memory is allocated by the allocator provided by the user and needs to be released. This pointer cannot be NULL.
int32_t *lenPointer to the length of the data written to the identity. The value cannot be empty.
OH_IPC_MemAllocator allocatorMemory allocator specified by the user for allocating memory for identity. It cannot be NULL.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if the parameters are incorrect.
Returns OH_IPC_ErrorCode#OH_IPC_MEM_ALLOCATOR_ERROR if the memory allocation fails.
Returns OH_IPC_ErrorCode#OH_IPC_INNER_ERROR in other cases.

OH_IPCSkeleton_SetCallingIdentity()

int OH_IPCSkeleton_SetCallingIdentity(const char *identity)

Description

Sets the caller credential information to the IPC context.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
const char *identityPointer to the caller credential, which cannot be empty. The value is returned by OH_IPCSkeleton_ResetCallingIdentity.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if the parameters are incorrect.
Returns OH_IPC_ErrorCode#OH_IPC_INNER_ERROR in other cases.

OH_IPCSkeleton_IsHandlingTransaction()

int OH_IPCSkeleton_IsHandlingTransaction(void)

Description

Checks whether an IPC request is being handled.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Returns

TypeDescription
intReturns 1 if an IPC request is being handled; returns 0 otherwise.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-ohipcremoteobject-oh-ipc-messageoption

openharmony 鸿蒙 capi-ipc-error-code-h

openharmony 鸿蒙 capi-ohipcremoteobject-ohipcdeathrecipient

openharmony 鸿蒙 capi-ohipcparcel

openharmony 鸿蒙 errorcode-rpc

openharmony 鸿蒙 capi-ohipcremoteobject

openharmony 鸿蒙 capi-ohipcskeleton

openharmony 鸿蒙 capi-ohipcparcel-ohipcremotestub

openharmony 鸿蒙 capi-ohipcparcel-ohipcremoteproxy

openharmony 鸿蒙 capi-ohipcerrorcode

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/ipnSaO1H