• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# ipc_cskeleton.h
2<!--Kit: IPC Kit-->
3<!--Subsystem: Communication-->
4<!--Owner: @xdx19211@luodonghui0157-->
5<!--Designer: @zhaopeng_gitee-->
6<!--Tester: @maxiaorong-->
7<!--Adviser: @zhang_yixin13-->
8
9## 概述
10
11提供IPC框架tokenId、凭据、PID/UID、线程池配置等功能C接口。
12
13**库:** libipc_capi.so
14
15**系统能力:** SystemCapability.Communication.IPC.Core
16
17**起始版本:** 12
18
19**相关模块:** [OHIPCSkeleton](capi-ohipcskeleton.md)
20
21## 汇总
22
23### 函数
24
25| 名称 | 描述 |
26| ---- | ---- |
27| [void OH_IPCSkeleton_JoinWorkThread(void)](#oh_ipcskeleton_joinworkthread) | 当前线程加入IPC工作线程池。 |
28| [void OH_IPCSkeleton_StopWorkThread(void)](#oh_ipcskeleton_stopworkthread) | 当前线程退出IPC工作线程池。 |
29| [uint64_t OH_IPCSkeleton_GetCallingTokenId(void)](#oh_ipcskeleton_getcallingtokenid) | 获取调用方TokenId。该接口需要在IPC上下文中调用,否则返回自身TokenId。 |
30| [uint64_t OH_IPCSkeleton_GetFirstTokenId(void)](#oh_ipcskeleton_getfirsttokenid) | 获取首调者TokenId。 |
31| [uint64_t OH_IPCSkeleton_GetSelfTokenId(void)](#oh_ipcskeleton_getselftokenid) | 获取自身TokenId。 |
32| [uint64_t OH_IPCSkeleton_GetCallingPid(void)](#oh_ipcskeleton_getcallingpid) | 获取调用方进程ID。该接口需要在IPC上下文中调用,否则返回当前进程ID。 |
33| [uint64_t OH_IPCSkeleton_GetCallingUid(void)](#oh_ipcskeleton_getcallinguid) | 获取调用方用户ID。该接口需要在IPC上下文中调用,否则返回当前用户ID。 |
34| [int OH_IPCSkeleton_IsLocalCalling(void)](#oh_ipcskeleton_islocalcalling) | 判断是否正在进行本地调用。 |
35| [int OH_IPCSkeleton_SetMaxWorkThreadNum(const int maxThreadNum)](#oh_ipcskeleton_setmaxworkthreadnum) | 设置最大工作线程数。 |
36| [int OH_IPCSkeleton_ResetCallingIdentity(char **identity, int32_t *len, OH_IPC_MemAllocator allocator)](#oh_ipcskeleton_resetcallingidentity) | 重置调用方身份凭证为自身进程的身份凭证(包括tokenid、UID和PID信息),并返回调用方的凭证信息。 该信息主要用于OH_IPCSkeleton_SetCallingIdentity接口调用。 |
37| [int OH_IPCSkeleton_SetCallingIdentity(const char *identity)](#oh_ipcskeleton_setcallingidentity) | 恢复调用方凭证信息至IPC上下文中。 |
38| [int OH_IPCSkeleton_IsHandlingTransaction(void)](#oh_ipcskeleton_ishandlingtransaction) | 是否正在处理IPC请求。 |
39
40## 函数说明
41
42### OH_IPCSkeleton_JoinWorkThread()
43
44```C
45void OH_IPCSkeleton_JoinWorkThread(void)
46```
47
48**描述:**
49
50当前线程加入IPC工作线程池。
51
52**系统能力:** SystemCapability.Communication.IPC.Core
53
54**起始版本:** 12
55
56### OH_IPCSkeleton_StopWorkThread()
57
58```C
59void OH_IPCSkeleton_StopWorkThread(void)
60```
61
62**描述:**
63
64当前线程退出IPC工作线程池。
65
66**系统能力:** SystemCapability.Communication.IPC.Core
67
68**起始版本:** 12
69
70### OH_IPCSkeleton_GetCallingTokenId()
71
72```C
73uint64_t OH_IPCSkeleton_GetCallingTokenId(void)
74```
75
76**描述:**
77
78获取调用方TokenId。该接口需要在IPC上下文中调用,否则返回自身TokenId。
79
80**系统能力:** SystemCapability.Communication.IPC.Core
81
82**起始版本:** 12
83
84**返回:**
85
86| 类型 | 说明 |
87| ---- | ---- |
88| uint64_t | 返回调用方TokenId。 |
89
90### OH_IPCSkeleton_GetFirstTokenId()
91
92```C
93uint64_t OH_IPCSkeleton_GetFirstTokenId(void)
94```
95
96**描述:**
97
98获取首调者TokenId。
99
100**系统能力:** SystemCapability.Communication.IPC.Core
101
102**起始版本:** 12
103
104**返回:**
105
106| 类型 | 说明 |
107| ---- | ---- |
108| uint64_t | 返回首调者TokenId。 |
109
110### OH_IPCSkeleton_GetSelfTokenId()
111
112```C
113uint64_t OH_IPCSkeleton_GetSelfTokenId(void)
114```
115
116**描述:**
117
118获取自身TokenId。
119
120**系统能力:** SystemCapability.Communication.IPC.Core
121
122**起始版本:** 12
123
124**返回:**
125
126| 类型 | 说明 |
127| ---- | ---- |
128| uint64_t | 返回自身TokenId。 |
129
130### OH_IPCSkeleton_GetCallingPid()
131
132```C
133uint64_t OH_IPCSkeleton_GetCallingPid(void)
134```
135
136**描述:**
137
138获取调用方进程ID。该接口需要在IPC上下文中调用,否则返回当前进程ID。
139
140**系统能力:** SystemCapability.Communication.IPC.Core
141
142**起始版本:** 12
143
144**返回:**
145
146| 类型 | 说明 |
147| ---- | ---- |
148| uint64_t | 返回调用方进程ID。 |
149
150### OH_IPCSkeleton_GetCallingUid()
151
152```C
153uint64_t OH_IPCSkeleton_GetCallingUid(void)
154```
155
156**描述:**
157
158获取调用方用户ID。该接口需要在IPC上下文中调用,否则返回当前用户ID。
159
160**系统能力:** SystemCapability.Communication.IPC.Core
161
162**起始版本:** 12
163
164**返回:**
165
166| 类型 | 说明 |
167| ---- | ---- |
168| uint64_t | 返回调用方用户ID。 |
169
170### OH_IPCSkeleton_IsLocalCalling()
171
172```C
173int OH_IPCSkeleton_IsLocalCalling(void)
174```
175
176**描述:**
177
178判断是否正在进行本地调用。
179
180**系统能力:** SystemCapability.Communication.IPC.Core
181
182**起始版本:** 12
183
184**返回:**
185
186| 类型 | 说明 |
187| ---- | ---- |
188| int | 正在进行本地调用,返回1;否则,返回0。 |
189
190### OH_IPCSkeleton_SetMaxWorkThreadNum()
191
192```C
193int OH_IPCSkeleton_SetMaxWorkThreadNum(const int maxThreadNum)
194```
195
196**描述:**
197
198设置最大工作线程数。
199
200**系统能力:** SystemCapability.Communication.IPC.Core
201
202**起始版本:** 12
203
204**参数:**
205
206| 参数项 | 描述 |
207| ------ | ---- |
208| const int maxThreadNum | maxThreadNum 最大工作线程数,默认16,范围:[1, 32]。 |
209
210**返回:**
211
212| 类型 | 说明 |
213| ---- | ---- |
214| int | 成功返回[OH_IPC_ErrorCode#OH_IPC_SUCCESS](capi-ipc-error-code-h.md#oh_ipc_errorcode);<br> 参数错误返回[OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](capi-ipc-error-code-h.md#oh_ipc_errorcode);<br> 其它情况返回[OH_IPC_ErrorCode#OH_IPC_INNER_ERROR](capi-ipc-error-code-h.md#oh_ipc_errorcode)。 |
215
216### OH_IPCSkeleton_ResetCallingIdentity()
217
218```C
219int OH_IPCSkeleton_ResetCallingIdentity(char **identity, int32_t *len, OH_IPC_MemAllocator allocator)
220```
221
222**描述:**
223
224重置调用方身份凭证为自身进程的身份凭证(包括tokenid、UID和PID信息),并返回调用方的凭证信息。 该信息主要用于OH_IPCSkeleton_SetCallingIdentity接口调用。
225
226**系统能力:** SystemCapability.Communication.IPC.Core
227
228**起始版本:** 12
229
230**参数:**
231
232| 参数项 | 描述 |
233| ------ | ---- |
234| char **identity | identity 用于存储调凭证的内存地址,该内存由用户提供的分配器进行内存分配,用户使用完后需要主动释放,不能为空。 |
235| int32_t *len | len 写入identity的数据长度,不能为空。 |
236| [OH_IPC_MemAllocator](capi-ipc-cparcel-h.md#oh_ipc_memallocator) allocator | allocator 用户指定的用来分配identity的内存分配器,不能为空。 |
237
238**返回:**
239
240| 类型 | 说明 |
241| ---- | ---- |
242| int | 成功返回[OH_IPC_ErrorCode#OH_IPC_SUCCESS](capi-ipc-error-code-h.md#oh_ipc_errorcode);<br> 参数错误返回[OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](capi-ipc-error-code-h.md#oh_ipc_errorcode);<br> 内存分配失败返回[OH_IPC_ErrorCode#OH_IPC_MEM_ALLOCATOR_ERROR](capi-ipc-error-code-h.md#oh_ipc_errorcode);<br> 其它情况返回[OH_IPC_ErrorCode#OH_IPC_INNER_ERROR](capi-ipc-error-code-h.md#oh_ipc_errorcode)。 |
243
244### OH_IPCSkeleton_SetCallingIdentity()
245
246```C
247int OH_IPCSkeleton_SetCallingIdentity(const char *identity)
248```
249
250**描述:**
251
252恢复调用方凭证信息至IPC上下文中。
253
254**系统能力:** SystemCapability.Communication.IPC.Core
255
256**起始版本:** 12
257
258**参数:**
259
260| 参数项 | 描述 |
261| ------ | ---- |
262| const char *identity | identity 调用方凭证,不能为空。来源于OH_IPCSkeleton_ResetCallingIdentity的返回值。 |
263
264**返回:**
265
266| 类型 | 说明 |
267| ---- | ---- |
268| int | 成功返回[OH_IPC_ErrorCode#OH_IPC_SUCCESS](capi-ipc-error-code-h.md#oh_ipc_errorcode);<br> 参数错误返回[OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](capi-ipc-error-code-h.md#oh_ipc_errorcode);<br> 其它情况返回[OH_IPC_ErrorCode#OH_IPC_INNER_ERROR](capi-ipc-error-code-h.md#oh_ipc_errorcode)。 |
269
270### OH_IPCSkeleton_IsHandlingTransaction()
271
272```C
273int OH_IPCSkeleton_IsHandlingTransaction(void)
274```
275
276**描述:**
277
278是否正在处理IPC请求。
279
280**系统能力:** SystemCapability.Communication.IPC.Core
281
282**起始版本:** 12
283
284**返回:**
285
286| 类型 | 说明 |
287| ---- | ---- |
288| int | 正在处理IPC请求,返回1;否则,返回0。 |
289