1 /* 2 * Copyright (c) 2020 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef SAMGR_IPC_ADAPTER_H 16 #define SAMGR_IPC_ADAPTER_H 17 18 #include "endpoint.h" 19 20 #include <log.h> 21 #include <ohos_errno.h> 22 #include <securec.h> 23 #include <service.h> 24 #include <stdlib.h> 25 #include <unistd.h> 26 27 #include "default_client.h" 28 #include "ipc_skeleton.h" 29 #include "iproxy_server.h" 30 #include "memory_adapter.h" 31 #include "policy_define.h" 32 #include "pthread.h" 33 #include "serializer.h" 34 #include "thread_adapter.h" 35 36 #ifdef __cplusplus 37 #if __cplusplus 38 extern "C" { 39 #endif 40 #endif 41 typedef struct RemoteRegister RemoteRegister; 42 struct RemoteRegister { 43 MutexId mtx; 44 Endpoint *endpoint; 45 Vector clients; 46 }; 47 48 #undef LOG_TAG 49 #undef LOG_DOMAIN 50 #define LOG_TAG "Samgr" 51 #define LOG_DOMAIN 0xD001800 52 53 #ifdef LITE_LINUX_BINDER_IPC 54 #define MAX_STACK_SIZE 0x100000 55 #else 56 #define MAX_STACK_SIZE 0x1000 57 #endif 58 #define MAX_OBJECT_NUM 5 59 #define MAX_RETRY_TIMES 300 60 #define RETRY_INTERVAL (50 * 1000) 61 #define MAX_REGISTER_RETRY_TIMES 10 62 #define REGISTER_RETRY_INTERVAL 2 63 #define MAX_POLICY_NUM 8 64 65 #ifndef MAX_BUCKET_RATE 66 #define MAX_BUCKET_RATE 1000 67 #endif 68 69 #ifndef MAX_BURST_RATE 70 #define MAX_BURST_RATE (MAX_BUCKET_RATE + (MAX_BUCKET_RATE >> 1)) 71 #endif 72 73 #define SAMGR_SERVICE "samgr" 74 75 typedef struct Router { 76 SaName saName; 77 Identity identity; 78 IServerProxy *proxy; 79 PolicyTrans *policy; 80 uint32 policyNum; 81 } Router; 82 83 int ClientRegisterRemoteEndpoint(SvcIdentity *identity, int token, const char *service, const char *feature); 84 void Listen(Endpoint *endpoint, int token, const char *service, const char *feature); 85 int RegisterIdentity(const SaName *saName, SvcIdentity *saInfo, PolicyTrans **policy, uint32 *policyNum); 86 int GetRemoteToken(IpcIo *data); 87 #ifdef __cplusplus 88 #if __cplusplus 89 } 90 #endif 91 #endif 92 #endif // LITE_DEFAULT_CLIENT_H 93