Yifan Hong | b0dde93 | 2017-02-10 17:49:58 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | |
| 17 | #ifndef FRAMEWORK_NATIVE_CMDS_LSHAL_TABLE_ENTRY_H_ |
| 18 | #define FRAMEWORK_NATIVE_CMDS_LSHAL_TABLE_ENTRY_H_ |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | |
| 22 | #include <string> |
| 23 | #include <vector> |
Yifan Hong | 38d53e0 | 2017-02-13 17:51:59 -0800 | [diff] [blame] | 24 | #include <iostream> |
Yifan Hong | b0dde93 | 2017-02-10 17:49:58 -0800 | [diff] [blame] | 25 | |
| 26 | namespace android { |
| 27 | namespace lshal { |
| 28 | |
| 29 | using Pids = std::vector<int32_t>; |
| 30 | |
| 31 | struct TableEntry { |
| 32 | std::string interfaceName; |
| 33 | std::string transport; |
| 34 | int32_t serverPid; |
Yifan Hong | ae09a3d | 2017-02-14 17:33:50 -0800 | [diff] [blame] | 35 | std::string serverCmdline; |
Yifan Hong | b0dde93 | 2017-02-10 17:49:58 -0800 | [diff] [blame] | 36 | uint64_t serverObjectAddress; |
| 37 | Pids clientPids; |
Yifan Hong | ae09a3d | 2017-02-14 17:33:50 -0800 | [diff] [blame] | 38 | std::vector<std::string> clientCmdlines; |
Yifan Hong | 38d53e0 | 2017-02-13 17:51:59 -0800 | [diff] [blame] | 39 | |
| 40 | static bool sortByInterfaceName(const TableEntry &a, const TableEntry &b) { |
| 41 | return a.interfaceName < b.interfaceName; |
| 42 | }; |
| 43 | static bool sortByServerPid(const TableEntry &a, const TableEntry &b) { |
| 44 | return a.serverPid < b.serverPid; |
| 45 | }; |
Yifan Hong | b0dde93 | 2017-02-10 17:49:58 -0800 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | using Table = std::vector<TableEntry>; |
Yifan Hong | 38d53e0 | 2017-02-13 17:51:59 -0800 | [diff] [blame] | 49 | using TableEntryCompare = std::function<bool(const TableEntry &, const TableEntry &)>; |
| 50 | |
| 51 | enum : unsigned int { |
| 52 | ENABLE_INTERFACE_NAME = 1 << 0, |
| 53 | ENABLE_TRANSPORT = 1 << 1, |
| 54 | ENABLE_SERVER_PID = 1 << 2, |
| 55 | ENABLE_SERVER_ADDR = 1 << 3, |
| 56 | ENABLE_CLIENT_PIDS = 1 << 4 |
| 57 | }; |
| 58 | |
| 59 | using TableEntrySelect = unsigned int; |
Yifan Hong | b0dde93 | 2017-02-10 17:49:58 -0800 | [diff] [blame] | 60 | |
| 61 | enum { |
| 62 | NO_PID = -1, |
| 63 | NO_PTR = 0 |
| 64 | }; |
| 65 | |
| 66 | } // namespace lshal |
| 67 | } // namespace android |
| 68 | |
| 69 | #endif // FRAMEWORK_NATIVE_CMDS_LSHAL_TABLE_ENTRY_H_ |