117fd14ceSopenharmony_ci/* 217fd14ceSopenharmony_ci * Copyright (C) 2021 Huawei Device Co., Ltd. 317fd14ceSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 417fd14ceSopenharmony_ci * you may not use this file except in compliance with the License. 517fd14ceSopenharmony_ci * You may obtain a copy of the License at 617fd14ceSopenharmony_ci * 717fd14ceSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 817fd14ceSopenharmony_ci * 917fd14ceSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1017fd14ceSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1117fd14ceSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1217fd14ceSopenharmony_ci * See the License for the specific language governing permissions and 1317fd14ceSopenharmony_ci * limitations under the License. 1417fd14ceSopenharmony_ci */ 1517fd14ceSopenharmony_ci 1617fd14ceSopenharmony_ci#ifndef IPC_ADAPT_H 1717fd14ceSopenharmony_ci#define IPC_ADAPT_H 1817fd14ceSopenharmony_ci 1917fd14ceSopenharmony_ci#include <stdint.h> 2017fd14ceSopenharmony_ci#include "device_auth.h" 2117fd14ceSopenharmony_ci 2217fd14ceSopenharmony_ci#ifdef __cplusplus 2317fd14ceSopenharmony_ciextern "C" { 2417fd14ceSopenharmony_ci#endif 2517fd14ceSopenharmony_ci 2617fd14ceSopenharmony_ci#define MAX_REQUEST_PARAMS_NUM 8 2717fd14ceSopenharmony_ci#define CB_TYPE_DEV_AUTH 1 2817fd14ceSopenharmony_ci#define CB_TYPE_TMP_DEV_AUTH 2 2917fd14ceSopenharmony_ci#define CB_TYPE_LISTENER 3 3017fd14ceSopenharmony_ci 3117fd14ceSopenharmony_citypedef struct { 3217fd14ceSopenharmony_ci int32_t type; 3317fd14ceSopenharmony_ci int32_t valSz; 3417fd14ceSopenharmony_ci uint8_t *val; 3517fd14ceSopenharmony_ci int32_t idx; 3617fd14ceSopenharmony_ci} IpcDataInfo; 3717fd14ceSopenharmony_ci 3817fd14ceSopenharmony_cienum { 3917fd14ceSopenharmony_ci CB_ID_ON_TRANS = 1, 4017fd14ceSopenharmony_ci CB_ID_SESS_KEY_DONE, 4117fd14ceSopenharmony_ci CB_ID_ON_FINISH, 4217fd14ceSopenharmony_ci CB_ID_ON_ERROR, 4317fd14ceSopenharmony_ci CB_ID_ON_REQUEST, 4417fd14ceSopenharmony_ci CB_ID_ON_GROUP_CREATED, 4517fd14ceSopenharmony_ci CB_ID_ON_GROUP_DELETED, 4617fd14ceSopenharmony_ci CB_ID_ON_DEV_BOUND, 4717fd14ceSopenharmony_ci CB_ID_ON_DEV_UNBOUND, 4817fd14ceSopenharmony_ci CB_ID_ON_DEV_UNTRUSTED, 4917fd14ceSopenharmony_ci CB_ID_ON_LAST_GROUP_DELETED, 5017fd14ceSopenharmony_ci CB_ID_ON_TRUST_DEV_NUM_CHANGED, 5117fd14ceSopenharmony_ci}; 5217fd14ceSopenharmony_ci 5317fd14ceSopenharmony_citypedef int32_t (*IpcServiceCall)(const IpcDataInfo *, int32_t, uintptr_t); 5417fd14ceSopenharmony_ci 5517fd14ceSopenharmony_ciint32_t IpcEncodeCallReply(uintptr_t replayCache, int32_t type, const uint8_t *result, int32_t resultSz); 5617fd14ceSopenharmony_ciuint32_t SetIpcCallMap(uintptr_t ipcInstance, IpcServiceCall method, int32_t methodId); 5717fd14ceSopenharmony_ci 5817fd14ceSopenharmony_civoid SetCbCtxToDataCtx(uintptr_t callCtx, int32_t cbIdx); 5917fd14ceSopenharmony_ciint32_t CreateCallCtx(uintptr_t *callCtx, uintptr_t *cbCtx); 6017fd14ceSopenharmony_civoid DestroyCallCtx(uintptr_t *callCtx, uintptr_t *cbCtx); 6117fd14ceSopenharmony_ciint32_t DoBinderCall(uintptr_t callCtx, int32_t methodId, bool withSync); 6217fd14ceSopenharmony_ciint32_t SetCallRequestParamInfo(uintptr_t callCtx, int32_t type, const uint8_t *param, int32_t paramSz); 6317fd14ceSopenharmony_ci 6417fd14ceSopenharmony_ciint32_t CreateServiceInstance(uintptr_t *ipcInstance); 6517fd14ceSopenharmony_civoid DestroyServiceInstance(uintptr_t ipcInstance); 6617fd14ceSopenharmony_ci 6717fd14ceSopenharmony_ciint32_t AddDevAuthServiceToManager(uintptr_t serviceInstance); 6817fd14ceSopenharmony_civoid DecodeCallReply(uintptr_t callCtx, IpcDataInfo *replyCache, int32_t cacheNum); 6917fd14ceSopenharmony_ci 7017fd14ceSopenharmony_ciint32_t InitIpcCallBackList(void); 7117fd14ceSopenharmony_civoid DeInitIpcCallBackList(void); 7217fd14ceSopenharmony_civoid InitDeviceAuthCbCtx(DeviceAuthCallback *ctx, int32_t type); 7317fd14ceSopenharmony_civoid InitDevAuthListenerCbCtx(DataChangeListener *ctx); 7417fd14ceSopenharmony_ciint32_t AddIpcCallBackByAppId(const char *appId, const uint8_t *cbPtr, int32_t cbSz, int32_t type); 7517fd14ceSopenharmony_civoid DelIpcCallBackByAppId(const char *appId, int32_t type); 7617fd14ceSopenharmony_ciint32_t AddIpcCallBackByReqId(int64_t reqId, const uint8_t *cbPtr, int32_t cbSz, int32_t type); 7717fd14ceSopenharmony_civoid DelIpcCallBackByReqId(int64_t reqId, int32_t type, bool withLock); 7817fd14ceSopenharmony_ci 7917fd14ceSopenharmony_ciint32_t DecodeIpcData(uintptr_t data, int32_t *type, uint8_t **val, int32_t *valSz); 8017fd14ceSopenharmony_civoid ProcCbHook(int32_t callbackId, uintptr_t cbHook, 8117fd14ceSopenharmony_ci const IpcDataInfo *cbDataCache, int32_t cacheNum, uintptr_t replyCtx); 8217fd14ceSopenharmony_ci 8317fd14ceSopenharmony_ciint32_t GetIpcRequestParamByType(const IpcDataInfo *ipcParams, int32_t paramNum, 8417fd14ceSopenharmony_ci int32_t type, uint8_t *paramCache, int32_t *cacheLen); 8517fd14ceSopenharmony_ciint32_t AddReqIdByAppId(const char *appId, int64_t reqId); 8617fd14ceSopenharmony_civoid AddIpcCbObjByAppId(const char *appId, int32_t objIdx, int32_t type); 8717fd14ceSopenharmony_civoid AddIpcCbObjByReqId(int64_t reqId, int32_t objIdx, int32_t type); 8817fd14ceSopenharmony_ci 8917fd14ceSopenharmony_cibool IsCallbackMethod(int32_t methodId); 9017fd14ceSopenharmony_civoid ResetIpcCallBackNodeByNodeId(int32_t nodeIdx); 9117fd14ceSopenharmony_ciint32_t InitProxyAdapt(void); 9217fd14ceSopenharmony_civoid UnInitProxyAdapt(void); 9317fd14ceSopenharmony_ci 9417fd14ceSopenharmony_ci#ifdef __cplusplus 9517fd14ceSopenharmony_ci} 9617fd14ceSopenharmony_ci#endif 9717fd14ceSopenharmony_ci#endif 98