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, |
Steven Moreland | f137de9 | 2021-04-24 01:54:26 +0000 | [diff] [blame^] | 50 | RPC_SPECIAL_TRANSACT_GET_MAX_THREADS = 1, |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | // serialization is like: |
| 54 | // |RpcWireHeader|struct desginated by 'command'| (over and over again) |
| 55 | |
| 56 | struct RpcWireHeader { |
| 57 | uint32_t command; // RPC_COMMAND_* |
| 58 | uint32_t bodySize; |
| 59 | |
| 60 | uint32_t reserved[2]; |
| 61 | }; |
| 62 | |
| 63 | struct RpcWireAddress { |
| 64 | uint8_t address[32]; |
| 65 | }; |
| 66 | |
| 67 | struct RpcWireTransaction { |
| 68 | RpcWireAddress address; |
| 69 | uint32_t code; |
| 70 | uint32_t flags; |
| 71 | |
| 72 | uint64_t asyncNumber; |
| 73 | |
| 74 | uint32_t reserved[4]; |
| 75 | |
| 76 | uint8_t data[0]; |
| 77 | }; |
| 78 | |
| 79 | struct RpcWireReply { |
| 80 | int32_t status; // transact return |
| 81 | uint8_t data[0]; |
| 82 | }; |
| 83 | |
| 84 | #pragma clang diagnostic pop |
| 85 | |
| 86 | } // namespace android |