1 /* 2 * Copyright (C) 2022 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 16 #ifndef OHOS_RPC_DBINDER_TYPES_H 17 #define OHOS_RPC_DBINDER_TYPES_H 18 19 #include <stdint.h> 20 21 #include "utils_list.h" 22 23 #include "serializer.h" 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 #define DEVICEID_LENGTH 64 30 #define SERVICENAME_LENGTH 200 31 #define VERSION_NUM 1 32 #define SESSION_NAME_LEGNTH 8 33 #define RPC_IPC_LENGTH 128 34 #define RPC_IPC_LENGTH_LONG 256 35 #define GET_SYSTEM_ABILITY_TRANSACTION 1 36 #define ID_DIGITS 10 37 #define USECTONSEC 1000 38 39 enum DBinderCode { 40 MESSAGE_AS_INVOKER = 1, 41 MESSAGE_AS_REPLY = 2, 42 MESSAGE_AS_OBITUARY = 3, 43 }; 44 45 enum AfType { 46 IPV4_TYPE = 1, 47 IPV6_TYPE = 2, 48 DATABBUS_TYPE = 3, 49 }; 50 51 enum { 52 DATABUS_TYPE 53 }; 54 55 struct DeviceIdInfo { 56 uint16_t afType; 57 uint16_t reserved; 58 char fromDeviceId[DEVICEID_LENGTH + 1]; 59 char toDeviceId[DEVICEID_LENGTH + 1]; 60 }; 61 62 struct DHandleEntryHead { 63 uint32_t len; 64 uint32_t version; 65 }; 66 67 typedef struct { 68 UTILS_DL_LIST list; 69 uint32_t type; 70 uint16_t toPort; 71 uint16_t fromPort; 72 uint64_t stubIndex; 73 uint32_t socketFd; 74 char serviceName[SERVICENAME_LENGTH + 1]; 75 struct DeviceIdInfo deviceIdInfo; 76 uintptr_t stub; 77 } SessionInfo; 78 79 typedef struct { 80 UTILS_DL_LIST list; 81 uintptr_t binderObject; 82 SvcIdentity *proxy; 83 char *sessionName; 84 uint32_t cbId; 85 } ProxyObject; 86 87 typedef struct { 88 uint32_t sizeOfSelf; 89 uint32_t magic; 90 uint32_t version; 91 int32_t cmd; 92 uint32_t code; 93 uint32_t flags; 94 uint64_t cookie; 95 uint64_t seqNumber; 96 uint64_t buffer_size; 97 uint64_t offsets_size; 98 uint64_t offsets; 99 char *buffer; 100 } dbinder_transaction_data; 101 102 typedef struct { 103 struct DHandleEntryHead head; 104 uint32_t transType; 105 uint32_t dBinderCode; 106 uint16_t fromPort; 107 uint16_t toPort; 108 uint64_t stubIndex; 109 uint32_t seqNumber; 110 uintptr_t binderObject; 111 struct DeviceIdInfo deviceIdInfo; 112 uintptr_t stub; 113 uint16_t serviceNameLength; 114 char serviceName[SERVICENAME_LENGTH + 1]; 115 uint32_t pid; 116 uint32_t uid; 117 } DHandleEntryTxRx; 118 119 #ifdef __cplusplus 120 } 121 #endif 122 #endif // OHOS_RPC_DBINDER_TYPES_H