commit
3f1e829712
|
@ -19,7 +19,7 @@ config("endpoint_public") {
|
|||
"//utils/native/lite/include",
|
||||
"//foundation/communication/ipc_lite/interfaces/kits",
|
||||
"//third_party/bounds_checking_function/include",
|
||||
"//base/security/permission/services/permission_lite/ipc_auth/include"
|
||||
"//base/security/permission/services/permission_lite/ipc_auth/include",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,10 @@ source_set("endpoint_source") {
|
|||
]
|
||||
|
||||
if (ohos_kernel_type == "linux") {
|
||||
defines = [ "LITE_LINUX_BINDER_IPC" ]
|
||||
defines = [
|
||||
"_GNU_SOURCE",
|
||||
"LITE_LINUX_BINDER_IPC",
|
||||
]
|
||||
}
|
||||
|
||||
configs += [ ":endpoint_internal" ]
|
||||
|
|
|
@ -13,11 +13,15 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "endpoint.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <securec.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ohos_errno.h>
|
||||
#include <service.h>
|
||||
#include <log.h>
|
||||
|
||||
#include "policy_define.h"
|
||||
#include "iproxy_server.h"
|
||||
#include "memory_adapter.h"
|
||||
|
@ -49,13 +53,6 @@
|
|||
#define MAX_BURST_RATE (MAX_BUCKET_RATE + (MAX_BUCKET_RATE >> 1))
|
||||
#endif
|
||||
|
||||
#ifndef MAX_SYSCAP_NUM
|
||||
#define MAX_SYSCAP_NUM 512
|
||||
#endif
|
||||
|
||||
#ifndef MAX_SYSCAP_NAME_LEN
|
||||
#define MAX_SYSCAP_NAME_LEN 64
|
||||
#endif
|
||||
#define SAMGR_SERVICE "samgr"
|
||||
|
||||
typedef struct Router {
|
||||
|
@ -166,7 +163,7 @@ int32 SAMGR_AddSysCap(const Endpoint *endpoint, const char *sysCap, BOOL isReg)
|
|||
}
|
||||
|
||||
if (replyBuf != NULL) {
|
||||
FreeBuffer(endpoint, replyBuf);
|
||||
FreeBuffer(endpoint->context, replyBuf);
|
||||
}
|
||||
HILOG_DEBUG(HILOG_MODULE_SAMGR, "SAMGR_AddSysCap ret = %d", ret);
|
||||
|
||||
|
@ -200,7 +197,7 @@ int32 SAMGR_GetSysCap(const Endpoint *endpoint, const char *sysCap, BOOL *isReg)
|
|||
*isReg = IpcIoPopBool(&reply);
|
||||
}
|
||||
if (replyBuf != NULL) {
|
||||
FreeBuffer(endpoint, replyBuf);
|
||||
FreeBuffer(endpoint->context, replyBuf);
|
||||
}
|
||||
HILOG_DEBUG(HILOG_MODULE_SAMGR, "SAMGR_GetSysCap ret = %d", ret);
|
||||
return ret;
|
||||
|
@ -235,7 +232,7 @@ static int32 ParseGetAllSysCapsReply(IpcIo *reply, char sysCaps[MAX_SYSCAP_NUM][
|
|||
size = ((size > MAX_SYSCAP_NUM) ? MAX_SYSCAP_NUM : size);
|
||||
int cnt = *sysCapNum;
|
||||
for (uint32 i = 0; i < size; i++) {
|
||||
int len = 0;
|
||||
uint32 len = 0;
|
||||
char *sysCap = (char *)IpcIoPopString(reply, &len);
|
||||
if (sysCap == NULL || len == 0) {
|
||||
continue;
|
||||
|
@ -263,7 +260,7 @@ int32 SAMGR_GetSystemCapabilities(const Endpoint *endpoint,
|
|||
HILOG_DEBUG(HILOG_MODULE_SAMGR, "SAMGR_GetSystemCapabilities begin");
|
||||
IpcIo reply;
|
||||
void *replyBuf = NULL;
|
||||
int startIdx = 0;
|
||||
uint32 startIdx = 0;
|
||||
BOOL isEnd = TRUE;
|
||||
int ret;
|
||||
do {
|
||||
|
@ -272,7 +269,7 @@ int32 SAMGR_GetSystemCapabilities(const Endpoint *endpoint,
|
|||
ret = ParseGetAllSysCapsReply(&reply, sysCaps, sysCapNum, &isEnd, &startIdx);
|
||||
}
|
||||
if (replyBuf != NULL) {
|
||||
FreeBuffer(endpoint, replyBuf);
|
||||
FreeBuffer(endpoint->context, replyBuf);
|
||||
}
|
||||
} while (isEnd == FALSE && ret == EC_SUCCESS);
|
||||
HILOG_DEBUG(HILOG_MODULE_SAMGR, "SAMGR_GetSystemCapabilities ret = %d", ret);
|
||||
|
@ -362,7 +359,7 @@ static void *Receive(void *argv)
|
|||
}
|
||||
|
||||
int ret = EC_INVALID;
|
||||
uint8 retry = 0;
|
||||
uint32 retry = 0;
|
||||
while (retry < MAX_RETRY_TIMES) {
|
||||
ret = endpoint->registerEP(endpoint->context, &endpoint->identity);
|
||||
if (ret == EC_SUCCESS) {
|
||||
|
@ -513,7 +510,7 @@ static int RegisterIdentity(const IpcContext *context, const SaName *saName, Svc
|
|||
ret = IpcIoPopInt32(&reply);
|
||||
}
|
||||
if (ret == EC_SUCCESS) {
|
||||
saInfo = IpcIoPopSvc(&reply);
|
||||
IpcIoPopSvc(&reply);
|
||||
GetRemotePolicy(&reply, policy, policyNum);
|
||||
}
|
||||
if (replyBuf != NULL) {
|
||||
|
@ -554,7 +551,7 @@ static int RegisterRemoteEndpoint(const IpcContext *context, SvcIdentity *identi
|
|||
IpcIoInit(&req, data, MAX_DATA_LEN, 0);
|
||||
IpcIoPushUint32(&req, RES_ENDPOINT);
|
||||
IpcIoPushUint32(&req, OP_POST);
|
||||
uint8 retry = 0;
|
||||
uint32 retry = 0;
|
||||
while (retry < MAX_RETRY_TIMES) {
|
||||
++retry;
|
||||
IpcIo reply;
|
||||
|
|
|
@ -32,6 +32,13 @@ extern "C" {
|
|||
#define SAMGR_COOKIE 0
|
||||
#define MAX_DATA_LEN 0x100
|
||||
#define MIN_DATA_LEN 0x40
|
||||
#ifndef MAX_SYSCAP_NUM
|
||||
#define MAX_SYSCAP_NUM 512
|
||||
#endif
|
||||
|
||||
#ifndef MAX_SYSCAP_NAME_LEN
|
||||
#define MAX_SYSCAP_NAME_LEN 64
|
||||
#endif
|
||||
|
||||
typedef enum ResourceID {
|
||||
RES_ENDPOINT,
|
||||
|
@ -64,6 +71,10 @@ struct Endpoint {
|
|||
Endpoint *SAMGR_CreateEndpoint(const char *name, RegisterEndpoint registry);
|
||||
int SAMGR_AddRouter(Endpoint *endpoint, const SaName *saName, const Identity *id, IUnknown *proxy);
|
||||
int SAMGR_ProcPolicy(const Endpoint *endpoint, const SaName *saName, int token);
|
||||
int32 SAMGR_AddSysCap(const Endpoint *endpoint, const char *sysCap, BOOL isReg);
|
||||
int32 SAMGR_GetSysCap(const Endpoint *endpoint, const char *sysCap, BOOL *isReg);
|
||||
int32 SAMGR_GetSystemCapabilities(const Endpoint *endpoint,
|
||||
char sysCaps[MAX_SYSCAP_NUM][MAX_SYSCAP_NAME_LEN], int32 *sysCapNum);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
|
|
@ -17,18 +17,21 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <ohos_init.h>
|
||||
#include <ohos_types.h>
|
||||
#include <ohos_errno.h>
|
||||
#include <liteipc.h>
|
||||
#include <liteipc_adapter.h>
|
||||
#include <log.h>
|
||||
|
||||
#include "cJSON.h"
|
||||
#include "default_client.h"
|
||||
#include "policy_define.h"
|
||||
#include "samgr_lite.h"
|
||||
#include "memory_adapter.h"
|
||||
#include "securec.h"
|
||||
#include "thread_adapter.h"
|
||||
#include "default_client.h"
|
||||
#include "memory_adapter.h"
|
||||
|
||||
#undef LOG_TAG
|
||||
#undef LOG_DOMAIN
|
||||
|
@ -380,7 +383,7 @@ static int32 ProcAddSysCap(SamgrServer *server, IpcIo *req)
|
|||
return EC_FAILURE;
|
||||
}
|
||||
SysCapImpl *serviceImpl = (SysCapImpl *)VECTOR_At(sysCapablitys, pos);
|
||||
if (serviceImpl == NULL || serviceImpl->name == NULL) {
|
||||
if (serviceImpl == NULL) {
|
||||
MUTEX_Unlock(server->sysCapMtx);
|
||||
return EC_FAILURE;
|
||||
}
|
||||
|
@ -389,7 +392,7 @@ static int32 ProcAddSysCap(SamgrServer *server, IpcIo *req)
|
|||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
static BOOL ProcGetSysCap(const SamgrServer *server, IpcIo *req)
|
||||
static BOOL ProcGetSysCap(SamgrServer *server, IpcIo *req)
|
||||
{
|
||||
size_t len = 0;
|
||||
char *sysCap = (char *)IpcIoPopString(req, &len);
|
||||
|
@ -415,7 +418,7 @@ static BOOL ProcGetSysCap(const SamgrServer *server, IpcIo *req)
|
|||
return res;
|
||||
}
|
||||
|
||||
static int32 GetReplyNumAndNextReqIdx(const Vector *sysCapablitys, int32 startIdx, int32 *nextRequestIdx)
|
||||
static int32 GetReplyNumAndNextReqIdx(Vector *sysCapablitys, int32 startIdx, int32 *nextRequestIdx)
|
||||
{
|
||||
int32 registerNum = 0;
|
||||
int32 size = VECTOR_Num(sysCapablitys);
|
||||
|
@ -431,7 +434,7 @@ static int32 GetReplyNumAndNextReqIdx(const Vector *sysCapablitys, int32 startId
|
|||
return registerNum;
|
||||
}
|
||||
|
||||
void ProcGetAllSysCap(const SamgrServer *server, IpcIo *req, IpcIo *reply)
|
||||
void ProcGetAllSysCap(SamgrServer *server, IpcIo *req, IpcIo *reply)
|
||||
{
|
||||
uint32_t startIdx = IpcIoPopUint32(req);
|
||||
MUTEX_Lock(server->sysCapMtx);
|
||||
|
|
Loading…
Reference in New Issue