| Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2020 The Android Open Source Project | 
|  | 3 | * | 
|  | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | * you may not use this file except in compliance with the License. | 
|  | 6 | * You may obtain a copy of the License at | 
|  | 7 | * | 
|  | 8 | *      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | * | 
|  | 10 | * Unless required by applicable law or agreed to in writing, software | 
|  | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | * See the License for the specific language governing permissions and | 
|  | 14 | * limitations under the License. | 
|  | 15 | */ | 
|  | 16 | #pragma once | 
|  | 17 |  | 
|  | 18 | namespace android { | 
|  | 19 |  | 
|  | 20 | #pragma clang diagnostic push | 
|  | 21 | #pragma clang diagnostic error "-Wpadded" | 
|  | 22 |  | 
|  | 23 | enum : uint32_t { | 
|  | 24 | /** | 
|  | 25 | * follows is RpcWireTransaction, if flags != oneway, reply w/ RPC_COMMAND_REPLY expected | 
|  | 26 | */ | 
|  | 27 | RPC_COMMAND_TRANSACT = 0, | 
|  | 28 | /** | 
|  | 29 | * follows is RpcWireReply | 
|  | 30 | */ | 
|  | 31 | RPC_COMMAND_REPLY, | 
|  | 32 | /** | 
|  | 33 | * follows is RpcWireAddress | 
|  | 34 | * | 
|  | 35 | * note - this in the protocol directly instead of as a 'special | 
|  | 36 | * transaction' in order to keep it as lightweight as possible (we don't | 
|  | 37 | * want to create a 'Parcel' object for every decref) | 
|  | 38 | */ | 
|  | 39 | RPC_COMMAND_DEC_STRONG, | 
|  | 40 | }; | 
|  | 41 |  | 
|  | 42 | /** | 
|  | 43 | * These commands are used when the address in an RpcWireTransaction is zero'd | 
|  | 44 | * out (no address). This allows the transact/reply flow to be used for | 
|  | 45 | * additional server commands, without making the protocol for | 
|  | 46 | * transactions/replies more complicated. | 
|  | 47 | */ | 
|  | 48 | enum : uint32_t { | 
|  | 49 | RPC_SPECIAL_TRANSACT_GET_ROOT = 0, | 
|  | 50 | }; | 
|  | 51 |  | 
|  | 52 | // serialization is like: | 
|  | 53 | // |RpcWireHeader|struct desginated by 'command'| (over and over again) | 
|  | 54 |  | 
|  | 55 | struct RpcWireHeader { | 
|  | 56 | uint32_t command; // RPC_COMMAND_* | 
|  | 57 | uint32_t bodySize; | 
|  | 58 |  | 
|  | 59 | uint32_t reserved[2]; | 
|  | 60 | }; | 
|  | 61 |  | 
|  | 62 | struct RpcWireAddress { | 
|  | 63 | uint8_t address[32]; | 
|  | 64 | }; | 
|  | 65 |  | 
|  | 66 | struct RpcWireTransaction { | 
|  | 67 | RpcWireAddress address; | 
|  | 68 | uint32_t code; | 
|  | 69 | uint32_t flags; | 
|  | 70 |  | 
|  | 71 | uint64_t asyncNumber; | 
|  | 72 |  | 
|  | 73 | uint32_t reserved[4]; | 
|  | 74 |  | 
|  | 75 | uint8_t data[0]; | 
|  | 76 | }; | 
|  | 77 |  | 
|  | 78 | struct RpcWireReply { | 
|  | 79 | int32_t status; // transact return | 
|  | 80 | uint8_t data[0]; | 
|  | 81 | }; | 
|  | 82 |  | 
|  | 83 | #pragma clang diagnostic pop | 
|  | 84 |  | 
|  | 85 | } // namespace android |