提交 42e14e99 编写于 作者: L liubb_0516

add rpc adapter file

Signed-off-by: Nliubb_0516 <liubeibei8@huawei.com>
上级 2f98bac9
......@@ -52,6 +52,7 @@ if (ohos_kernel_type == "liteos_m") {
"//utils/native/lite/include",
"$hilog_lite_include_path",
]
deps = [ "//foundation/communication/ipc/ipc/native/c/adapter:rpc_adapter" ]
}
} else {
shared_library("rpc_log") {
......@@ -91,6 +92,7 @@ if (ohos_kernel_type == "liteos_m") {
]
public_deps = [
":rpc_log",
"//foundation/communication/ipc/ipc/native/c/adapter:rpc_adapter",
"//third_party/bounds_checking_function/:libsec_shared",
]
......
# Copyright (c) 2020 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
config("rpc_adapter_interface") {
include_dirs = [ "include" ]
}
if (ohos_kernel_type == "liteos_m") {
static_library("rpc_adapter") {
sources = [ "Liteos_m/rpc_os_adapter.c" ]
public_configs = [ ":rpc_adapter_interface" ]
}
} else {
shared_library("rpc_adapter") {
sources = [ "Linux/rpc_os_adapter.c" ]
public_configs = [ ":rpc_adapter_interface" ]
ldflags = [
"-lstdc++",
"-fPIC",
]
}
}
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <unistd.h>
#include "rpc_os_adapter.h"
int32_t RpcGetPid()
{
return (int32_t)getpid();
}
int32_t RpcGetUid()
{
return (int32_t)getuid();
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "rpc_os_adapter.h"
int32_t RpcGetPid()
{
return 0;
}
int32_t RpcGetUid()
{
return 0;
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_IPC_RPC_OS_ADAPTER_H
#define OHOS_IPC_RPC_OS_ADAPTER_H
#include <stdint.h>
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */
int32_t RpcGetPid();
int32_t RpcGetUid();
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */
#endif /* OHOS_IPC_RPC_OS_ADAPTER_H */
......@@ -19,8 +19,10 @@
#include "iremote_invoker.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */
RemoteInvoker *GetIpcInvoker(void);
int32_t AcquireHandle(int32_t handle);
......@@ -35,6 +37,8 @@ int32_t IpcRemoveDeathRecipient(int32_t handle, void *cookie);
void IpcExitCurrentThread(void);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif // OHOS_IPC_INVOKER_H
\ No newline at end of file
#endif /* __cplusplus */
#endif /* OHOS_IPC_INVOKER_H */
\ No newline at end of file
......@@ -30,6 +30,7 @@
#include "ipc_thread_pool.h"
#include "rpc_errno.h"
#include "rpc_log.h"
#include "rpc_os_adapter.h"
#include "rpc_types.h"
#include "securec.h"
#include "sys_binder.h"
......@@ -141,8 +142,8 @@ static void ToTransData(uint32_t handle, uint32_t code, MessageOption option, co
buf->btd.code = code;
buf->btd.flags = option;
buf->btd.cookie = 0;
buf->btd.sender_pid = getpid();
buf->btd.sender_euid = getuid();
buf->btd.sender_pid = RpcGetPid();
buf->btd.sender_euid = RpcGetUid();
buf->btd.data_size = (data == NULL) ? 0 : (data->bufferCur - data->bufferBase);
buf->btd.data.ptr.buffer = (data == NULL) ? 0 : (binder_uintptr_t)data->bufferBase;
buf->btd.offsets_size = (data == NULL) ? 0 : ((char*)data->offsetsCur - (char*)data->offsetsBase);
......
......@@ -19,6 +19,7 @@
#include "iremote_invoker.h"
#include "rpc_errno.h"
#include "rpc_log.h"
#include "rpc_os_adapter.h"
#include "rpc_types.h"
#include "securec.h"
#include "utils_list.h"
......@@ -125,7 +126,7 @@ pid_t ProcessGetCallingPid()
if (currentContext != NULL) {
return currentContext->callerPid;
}
return getpid();
return RpcGetPid();
}
pid_t ProcessGetCallingUid()
......@@ -134,7 +135,7 @@ pid_t ProcessGetCallingUid()
if (currentContext != NULL) {
return currentContext->callerUid;
}
return getuid();
return RpcGetUid();
}
const SvcIdentity *GetRegistryObject(void)
......
......@@ -21,6 +21,7 @@
#include "iremote_invoker.h"
#include "rpc_errno.h"
#include "rpc_log.h"
#include "rpc_os_adapter.h"
#include "rpc_types.h"
#include "securec.h"
......@@ -156,8 +157,8 @@ ThreadContext *GetCurrentThreadContext(void)
}
current->threadId = pthread_self();
current->proto = IF_PROT_DEFAULT;
current->callerPid = getpid();
current->callerUid = getuid();
current->callerPid = RpcGetPid();
current->callerUid = RpcGetUid();
pthread_setspecific(g_localKey, current);
}
return current;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册