Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
communication_ipc
提交
c1970b93
C
communication_ipc
项目概览
OpenHarmony
/
communication_ipc
大约 1 年 前同步成功
通知
20
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
communication_ipc
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c1970b93
编写于
1月 18, 2022
作者:
Y
yangguangzhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code review fixed
Signed-off-by:
N
yangguangzhao
<
yangguangzhao1@huawei.com
>
上级
79e70a70
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
99 addition
and
85 deletion
+99
-85
interfaces/innerkits/c/dbinder/include/dbinder_service.h
interfaces/innerkits/c/dbinder/include/dbinder_service.h
+0
-26
ipc/native/c/rpc/ipc_adapter/mini/ipc_proxy_inner.c
ipc/native/c/rpc/ipc_adapter/mini/ipc_proxy_inner.c
+1
-0
ipc/native/c/rpc/trans_adapter/include/rpc_trans.h
ipc/native/c/rpc/trans_adapter/include/rpc_trans.h
+1
-1
ipc/native/c/rpc/trans_adapter/src/rpc_trans.c
ipc/native/c/rpc/trans_adapter/src/rpc_trans.c
+0
-9
ipc/test/rpc/client/rpc_client.c
ipc/test/rpc/client/rpc_client.c
+1
-6
ipc/test/rpc/socket_trans/include/rpc_socket_trans.h
ipc/test/rpc/socket_trans/include/rpc_socket_trans.h
+0
-1
ipc/test/rpc/socket_trans/src/rpc_mini_socket_trans.c
ipc/test/rpc/socket_trans/src/rpc_mini_socket_trans.c
+17
-16
ipc/test/rpc/socket_trans/src/rpc_socket_trans.c
ipc/test/rpc/socket_trans/src/rpc_socket_trans.c
+21
-20
services/dbinder/c/include/dbinder_service_inner.h
services/dbinder/c/include/dbinder_service_inner.h
+35
-0
services/dbinder/c/include/dbinder_trans_callback.h
services/dbinder/c/include/dbinder_trans_callback.h
+0
-1
services/dbinder/c/include/dbinder_types.h
services/dbinder/c/include/dbinder_types.h
+17
-0
services/dbinder/c/src/dbinder_service.c
services/dbinder/c/src/dbinder_service.c
+4
-3
services/dbinder/c/src/dbinder_stub.c
services/dbinder/c/src/dbinder_stub.c
+1
-1
services/dbinder/c/src/dbinder_trans_callback.c
services/dbinder/c/src/dbinder_trans_callback.c
+1
-1
未找到文件。
interfaces/innerkits/c/dbinder/include/dbinder_service.h
浏览文件 @
c1970b93
...
...
@@ -16,44 +16,18 @@
#ifndef DBINDER_SERVICE_H
#define DBINDER_SERVICE_H
#include <pthread.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdint.h>
#include "dbinder_types.h"
#include "utils_list.h"
#ifdef __cplusplus
#if __cplusplus
extern
"C"
{
#endif
#endif
typedef
struct
{
struct
DHandleEntryHead
head
;
uint32_t
transType
;
uint32_t
dBinderCode
;
uint16_t
fromPort
;
uint16_t
toPort
;
uint64_t
stubIndex
;
uint32_t
seqNumber
;
uintptr_t
binderObject
;
struct
DeviceIdInfo
deviceIdInfo
;
uintptr_t
stub
;
uint16_t
serviceNameLength
;
char
serviceName
[
SERVICENAME_LENGTH
+
1
];
uint32_t
pid
;
uint32_t
uid
;
}
DHandleEntryTxRx
;
int32_t
StartDBinderService
(
void
);
int32_t
RegisterRemoteProxy
(
const
void
*
name
,
uint32_t
len
,
int32_t
systemAbility
);
int32_t
MakeRemoteBinder
(
const
void
*
serviceName
,
uint32_t
nameLen
,
const
char
*
deviceID
,
uint32_t
idLen
,
uintptr_t
binderObject
,
uint64_t
pid
,
void
*
remoteObject
);
int32_t
OnRemoteMessageTask
(
const
DHandleEntryTxRx
*
message
);
SessionInfo
*
QuerySessionObject
(
uintptr_t
stub
);
void
DetachProxyObject
(
ProxyObject
*
proxy
);
#ifdef __cplusplus
#if __cplusplus
...
...
ipc/native/c/rpc/ipc_adapter/mini/ipc_proxy_inner.c
浏览文件 @
c1970b93
...
...
@@ -23,6 +23,7 @@
#include "rpc_process_skeleton.h"
#include "dbinder_invoker.h"
#include "dbinder_types.h"
#include "dbinder_service_inner.h"
#include "rpc_errno.h"
#include "rpc_log.h"
...
...
ipc/native/c/rpc/trans_adapter/include/rpc_trans.h
浏览文件 @
c1970b93
...
...
@@ -34,10 +34,10 @@ typedef struct {
int32_t
(
*
Connect
)(
const
char
*
SaSessionName
,
const
char
*
peerDeviceId
,
void
*
args
);
int32_t
(
*
Disconnect
)(
int32_t
sessionId
);
int32_t
(
*
Send
)(
int32_t
sessionId
,
const
void
*
data
,
uint32_t
len
);
char
(
*
GetLocalDeviceID
)(
void
);
}
TransInterface
;
TransInterface
*
GetRpcTrans
(
void
);
char
*
GetLocalDeviceID
(
void
);
#ifdef __cplusplus
}
...
...
ipc/native/c/rpc/trans_adapter/src/rpc_trans.c
浏览文件 @
c1970b93
...
...
@@ -27,14 +27,5 @@ TransInterface *GetRpcTrans(void)
return
GetSocketTrans
();
#endif
return
NULL
;
}
char
*
GetLocalDeviceID
(
void
)
{
#if defined(RPC_SOCKET_TRANS)
return
GetSocketLocalDeviceID
();
#endif
return
NULL
;
}
\ No newline at end of file
ipc/test/rpc/client/rpc_client.c
浏览文件 @
c1970b93
...
...
@@ -106,13 +106,8 @@ int main(int argc, char *argv[])
return
-
1
;
}
RPC_LOG_INFO
(
"argv 1 is %s"
,
argv
[
1
]);
if
(
strcmp
(
argv
[
1
],
"deviceId"
)
==
0
)
{
RPC_LOG_INFO
(
"local deviceId is %s"
,
GetLocalDeviceID
());
return
0
;
}
const
char
*
deviceId
=
argv
[
1
];
RPC_LOG_INFO
(
"input deviceid is %s"
,
deviceId
);
IpcIo
data1
;
uint8_t
tmpData1
[
IPC_LENGTH
];
...
...
ipc/test/rpc/socket_trans/include/rpc_socket_trans.h
浏览文件 @
c1970b93
...
...
@@ -34,7 +34,6 @@ static const uint16_t DEFAULT_HASH_SEED = 5381;
static
const
uint16_t
DEFAULT_PORT_MIN
=
10000
;
TransInterface
*
GetSocketTrans
(
void
);
char
*
GetSocketLocalDeviceID
(
void
);
#ifdef __cplusplus
}
...
...
ipc/test/rpc/socket_trans/src/rpc_mini_socket_trans.c
浏览文件 @
c1970b93
...
...
@@ -353,12 +353,28 @@ static int32_t Send(int32_t sessionId, const void *data, uint32_t len)
return
ERR_NONE
;
}
static
char
*
GetSocketLocalDeviceID
(
void
)
{
extern
struct
netif
if_wifi
;
uint32_t
ip
=
((
ip4_addr_t
*
)
&
if_wifi
.
ip_addr
)
->
addr
;
char
*
localDeviceId
=
inet_ntoa
(
ip
);
if
(
localDeviceId
==
NULL
)
{
RPC_LOG_ERROR
(
"GetSocketLocalDeviceID inet_ntoa return null"
);
return
NULL
;
}
RPC_LOG_INFO
(
"GetSocketLocalDeviceID %s
\n
"
,
localDeviceId
);
return
localDeviceId
;
}
static
TransInterface
g_socketTrans
=
{
.
StartListen
=
StartListen
,
.
StopListen
=
StopListen
,
.
Connect
=
Connect
,
.
Disconnect
=
Disconnect
,
.
Send
=
Send
.
Send
=
Send
,
.
GetLocalDeviceID
=
GetSocketLocalDeviceID
};
TransInterface
*
GetSocketTrans
(
void
)
...
...
@@ -371,19 +387,4 @@ TransInterface *GetSocketTrans(void)
pthread_mutex_unlock
(
&
g_socketNodeList
.
mutex
);
}
return
&
g_socketTrans
;
}
char
*
GetSocketLocalDeviceID
(
void
)
{
extern
struct
netif
if_wifi
;
uint32_t
ip
=
((
ip4_addr_t
*
)
&
if_wifi
.
ip_addr
)
->
addr
;
char
*
localDeviceId
=
inet_ntoa
(
ip
);
if
(
localDeviceId
==
NULL
)
{
RPC_LOG_ERROR
(
"GetSocketLocalDeviceID inet_ntoa return null"
);
return
NULL
;
}
RPC_LOG_INFO
(
"GetSocketLocalDeviceID %s
\n
"
,
localDeviceId
);
return
localDeviceId
;
}
\ No newline at end of file
ipc/test/rpc/socket_trans/src/rpc_socket_trans.c
浏览文件 @
c1970b93
...
...
@@ -296,26 +296,7 @@ static int32_t Send(int32_t sessionId, const void *data, uint32_t len)
return
ERR_NONE
;
}
static
TransInterface
g_socketTrans
=
{
.
StartListen
=
StartListen
,
.
StopListen
=
StopListen
,
.
Connect
=
Connect
,
.
Disconnect
=
Disconnect
,
.
Send
=
Send
};
TransInterface
*
GetSocketTrans
(
void
)
{
if
(
g_init
==
-
1
)
{
pthread_mutex_lock
(
&
g_socketNodeList
.
mutex
);
UtilsListInit
(
&
g_socketNodeList
.
list
);
g_init
=
0
;
pthread_mutex_unlock
(
&
g_socketNodeList
.
mutex
);
}
return
&
g_socketTrans
;
}
char
*
GetSocketLocalDeviceID
(
void
)
static
char
*
GetSocketLocalDeviceID
(
void
)
{
if
(
g_localDeviceId
!=
NULL
)
{
return
g_localDeviceId
;
...
...
@@ -365,4 +346,24 @@ char *GetSocketLocalDeviceID(void)
freeifaddrs
(
ifaddr
);
return
g_localDeviceId
;
}
static
TransInterface
g_socketTrans
=
{
.
StartListen
=
StartListen
,
.
StopListen
=
StopListen
,
.
Connect
=
Connect
,
.
Disconnect
=
Disconnect
,
.
Send
=
Send
,
.
GetLocalDeviceID
=
GetSocketLocalDeviceID
,
};
TransInterface
*
GetSocketTrans
(
void
)
{
if
(
g_init
==
-
1
)
{
pthread_mutex_lock
(
&
g_socketNodeList
.
mutex
);
UtilsListInit
(
&
g_socketNodeList
.
list
);
g_init
=
0
;
pthread_mutex_unlock
(
&
g_socketNodeList
.
mutex
);
}
return
&
g_socketTrans
;
}
\ No newline at end of file
services/dbinder/c/include/dbinder_service_inner.h
0 → 100644
浏览文件 @
c1970b93
/*
* Copyright (C) 2022 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 DBINDER_SERVICE_INNER_H
#define DBINDER_SERVICE_INNER_H
#include "dbinder_types.h"
#ifdef __cplusplus
#if __cplusplus
extern
"C"
{
#endif
#endif
/* __cplusplus */
int32_t
OnRemoteMessageTask
(
const
DHandleEntryTxRx
*
message
);
SessionInfo
*
QuerySessionObject
(
uintptr_t
stub
);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
/* __cplusplus */
#endif
/* DBINDER_SERVICE_INNER_H */
\ No newline at end of file
services/dbinder/c/include/dbinder_trans_callback.h
浏览文件 @
c1970b93
...
...
@@ -20,7 +20,6 @@
#include <stdlib.h>
#include "rpc_trans.h"
#include "dbinder_service.h"
#ifdef __cplusplus
extern
"C"
{
...
...
services/dbinder/c/include/dbinder_types.h
浏览文件 @
c1970b93
...
...
@@ -99,6 +99,23 @@ typedef struct {
char
*
buffer
;
}
dbinder_transaction_data
;
typedef
struct
{
struct
DHandleEntryHead
head
;
uint32_t
transType
;
uint32_t
dBinderCode
;
uint16_t
fromPort
;
uint16_t
toPort
;
uint64_t
stubIndex
;
uint32_t
seqNumber
;
uintptr_t
binderObject
;
struct
DeviceIdInfo
deviceIdInfo
;
uintptr_t
stub
;
uint16_t
serviceNameLength
;
char
serviceName
[
SERVICENAME_LENGTH
+
1
];
uint32_t
pid
;
uint32_t
uid
;
}
DHandleEntryTxRx
;
#ifdef __cplusplus
}
#endif
...
...
services/dbinder/c/src/dbinder_service.c
浏览文件 @
c1970b93
...
...
@@ -27,6 +27,7 @@
#include "rpc_trans.h"
#include "dbinder_trans_callback.h"
#include "dbinder_ipc_adapter.h"
#include "dbinder_service_inner.h"
#include "serializer.h"
#include "dbinder_stub.h"
#include "ipc_skeleton.h"
...
...
@@ -214,7 +215,7 @@ static int32_t SendEntryToRemote(DBinderServiceStub *stub, const uint32_t seqNum
}
uint32_t
toDeviceIDLength
=
(
uint32_t
)
strlen
(
toDeviceID
);
char
*
localDeviceID
=
GetLocalDeviceID
();
char
*
localDeviceID
=
g_trans
->
GetLocalDeviceID
();
if
(
localDeviceID
==
NULL
)
{
RPC_LOG_ERROR
(
"GetLocalDeviceID failed"
);
return
ERR_FAILED
;
...
...
@@ -400,7 +401,7 @@ static int32_t AttachProxyObject(ProxyObject *proxy)
return
ERR_NONE
;
}
void
DetachProxyObject
(
ProxyObject
*
proxy
)
static
void
DetachProxyObject
(
ProxyObject
*
proxy
)
{
pthread_mutex_lock
(
&
g_proxyObjectList
.
mutex
);
UtilsListDelete
(
&
proxy
->
list
);
...
...
@@ -496,7 +497,7 @@ static int32_t OnRemoteInvokerDataBusMessage(ProxyObject *proxy, DHandleEntryTxR
IpcIo
reply
;
uintptr_t
ptr
;
int32_t
ret
=
InvokerListenThread
(
proxy
,
GetLocalDeviceID
(),
remoteDeviceID
,
pid
,
uid
,
&
reply
,
&
ptr
);
int32_t
ret
=
InvokerListenThread
(
proxy
,
g_trans
->
GetLocalDeviceID
(),
remoteDeviceID
,
pid
,
uid
,
&
reply
,
&
ptr
);
if
(
ret
!=
ERR_NONE
)
{
RPC_LOG_ERROR
(
"INVOKE_LISTEN_THREAD failed"
);
FreeBuffer
((
void
*
)
ptr
);
...
...
services/dbinder/c/src/dbinder_stub.c
浏览文件 @
c1970b93
...
...
@@ -24,8 +24,8 @@
#include "ipc_thread_pool.h"
#include "ipc_skeleton.h"
#include "ipc_process_skeleton.h"
#include "dbinder_service.h"
#include "dbinder_ipc_adapter.h"
#include "dbinder_service_inner.h"
#define IPC_INVALID_HANDLE (-1)
...
...
services/dbinder/c/src/dbinder_trans_callback.c
浏览文件 @
c1970b93
...
...
@@ -17,7 +17,7 @@
#include <stdbool.h>
#include "dbinder_service.h"
#include "dbinder_service
_inner
.h"
#include "rpc_log.h"
#include "rpc_errno.h"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录