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 LITE_ENDPOINT_H 16 #define LITE_ENDPOINT_H 17 18 #include <stddef.h> 19 #include "common.h" 20 #include "iproxy_server.h" 21 #include "default_client.h" 22 #include "token_bucket.h" 23 24 #ifdef __cplusplus 25 #if __cplusplus 26 extern "C" { 27 #endif 28 #endif 29 30 #define SAMGR_HANDLE 0 31 #define SAMGR_TOKEN 0 32 #define SAMGR_COOKIE 0 33 #define MAX_DATA_LEN 0x100 34 #define MIN_DATA_LEN 0x40 35 #ifndef MAX_SYSCAP_NUM 36 #define MAX_SYSCAP_NUM 512 37 #endif 38 39 #ifndef MAX_SYSCAP_NAME_LEN 40 #define MAX_SYSCAP_NAME_LEN 64 41 #endif 42 43 typedef enum ResourceID { 44 RES_ENDPOINT, 45 RES_FEATURE, 46 RES_SYSCAP, 47 RES_BUTT, 48 } ResourceID; 49 50 typedef enum OptionID { 51 OP_GET, 52 OP_POST, 53 OP_PUT, 54 OP_DELETE, 55 OP_ALL, 56 } OptionID; 57 typedef struct Endpoint Endpoint; 58 typedef int (*RegisterEndpoint)(SvcIdentity *identity, int token, const char *service, const char *feature); 59 60 struct Endpoint { 61 const char *name; 62 Vector routers; 63 ThreadId boss; 64 uint32 deadId; 65 int running; 66 SvcIdentity identity; 67 RegisterEndpoint registerEP; 68 TokenBucket bucket; 69 }; 70 71 Endpoint *SAMGR_CreateEndpoint(const char *name, RegisterEndpoint registry); 72 int SAMGR_AddRouter(Endpoint *endpoint, const SaName *saName, const Identity *id, IUnknown *proxy); 73 int SAMGR_ProcPolicy(const Endpoint *endpoint, const SaName *saName, int token); 74 int32 SAMGR_AddSysCap(const Endpoint *endpoint, const char *sysCap, BOOL isReg); 75 int32 SAMGR_GetSysCap(const Endpoint *endpoint, const char *sysCap, BOOL *isReg); 76 int32 SAMGR_GetSystemCapabilities(const Endpoint *endpoint, 77 char sysCaps[MAX_SYSCAP_NUM][MAX_SYSCAP_NAME_LEN], int32 *sysCapNum); 78 79 #ifdef __cplusplus 80 #if __cplusplus 81 } 82 #endif 83 #endif 84 #endif // LITE_ENDPOINT_H 85