The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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 __ADB_H |
| 18 | #define __ADB_H |
| 19 | |
| 20 | #include <limits.h> |
| 21 | |
leozwang | d3fc15f | 2014-07-29 12:50:02 -0700 | [diff] [blame] | 22 | #include "adb_trace.h" |
Dan Albert | 630b9af | 2014-11-24 23:34:35 -0800 | [diff] [blame] | 23 | #include "fdevent.h" |
JP Abgrall | 408fa57 | 2011-03-16 15:57:42 -0700 | [diff] [blame] | 24 | #include "transport.h" /* readx(), writex() */ |
| 25 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 26 | #define MAX_PAYLOAD 4096 |
| 27 | |
| 28 | #define A_SYNC 0x434e5953 |
| 29 | #define A_CNXN 0x4e584e43 |
| 30 | #define A_OPEN 0x4e45504f |
| 31 | #define A_OKAY 0x59414b4f |
| 32 | #define A_CLSE 0x45534c43 |
| 33 | #define A_WRTE 0x45545257 |
Benoit Goby | d5fcafa | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 34 | #define A_AUTH 0x48545541 |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 35 | |
| 36 | #define A_VERSION 0x01000000 // ADB protocol version |
| 37 | |
| 38 | #define ADB_VERSION_MAJOR 1 // Used for help/version information |
| 39 | #define ADB_VERSION_MINOR 0 // Used for help/version information |
| 40 | |
Doug Zongker | 71fe584 | 2014-06-26 15:35:36 -0700 | [diff] [blame] | 41 | #define ADB_SERVER_VERSION 32 // Increment this when we want to force users to start a new adb server |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 42 | |
| 43 | typedef struct amessage amessage; |
| 44 | typedef struct apacket apacket; |
| 45 | typedef struct asocket asocket; |
| 46 | typedef struct alistener alistener; |
| 47 | typedef struct aservice aservice; |
| 48 | typedef struct atransport atransport; |
| 49 | typedef struct adisconnect adisconnect; |
| 50 | typedef struct usb_handle usb_handle; |
| 51 | |
| 52 | struct amessage { |
| 53 | unsigned command; /* command identifier constant */ |
| 54 | unsigned arg0; /* first argument */ |
| 55 | unsigned arg1; /* second argument */ |
| 56 | unsigned data_length; /* length of payload (0 is allowed) */ |
| 57 | unsigned data_check; /* checksum of data payload */ |
| 58 | unsigned magic; /* command ^ 0xffffffff */ |
| 59 | }; |
| 60 | |
| 61 | struct apacket |
| 62 | { |
| 63 | apacket *next; |
| 64 | |
| 65 | unsigned len; |
| 66 | unsigned char *ptr; |
| 67 | |
| 68 | amessage msg; |
| 69 | unsigned char data[MAX_PAYLOAD]; |
| 70 | }; |
| 71 | |
| 72 | /* An asocket represents one half of a connection between a local and |
| 73 | ** remote entity. A local asocket is bound to a file descriptor. A |
| 74 | ** remote asocket is bound to the protocol engine. |
| 75 | */ |
| 76 | struct asocket { |
| 77 | /* chain pointers for the local/remote list of |
| 78 | ** asockets that this asocket lives in |
| 79 | */ |
| 80 | asocket *next; |
| 81 | asocket *prev; |
| 82 | |
| 83 | /* the unique identifier for this asocket |
| 84 | */ |
| 85 | unsigned id; |
| 86 | |
| 87 | /* flag: set when the socket's peer has closed |
| 88 | ** but packets are still queued for delivery |
| 89 | */ |
| 90 | int closing; |
| 91 | |
Benoit Goby | f366b36 | 2012-03-16 14:50:07 -0700 | [diff] [blame] | 92 | /* flag: quit adbd when both ends close the |
| 93 | ** local service socket |
| 94 | */ |
| 95 | int exit_on_close; |
| 96 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 97 | /* the asocket we are connected to |
| 98 | */ |
| 99 | |
| 100 | asocket *peer; |
| 101 | |
| 102 | /* For local asockets, the fde is used to bind |
| 103 | ** us to our fd event system. For remote asockets |
| 104 | ** these fields are not used. |
| 105 | */ |
| 106 | fdevent fde; |
| 107 | int fd; |
| 108 | |
| 109 | /* queue of apackets waiting to be written |
| 110 | */ |
| 111 | apacket *pkt_first; |
| 112 | apacket *pkt_last; |
| 113 | |
| 114 | /* enqueue is called by our peer when it has data |
| 115 | ** for us. It should return 0 if we can accept more |
| 116 | ** data or 1 if not. If we return 1, we must call |
| 117 | ** peer->ready() when we once again are ready to |
| 118 | ** receive data. |
| 119 | */ |
| 120 | int (*enqueue)(asocket *s, apacket *pkt); |
| 121 | |
| 122 | /* ready is called by the peer when it is ready for |
| 123 | ** us to send data via enqueue again |
| 124 | */ |
| 125 | void (*ready)(asocket *s); |
| 126 | |
David 'Digit' Turner | 818d641 | 2013-12-13 14:09:44 +0100 | [diff] [blame] | 127 | /* shutdown is called by the peer before it goes away. |
| 128 | ** the socket should not do any further calls on its peer. |
| 129 | ** Always followed by a call to close. Optional, i.e. can be NULL. |
| 130 | */ |
| 131 | void (*shutdown)(asocket *s); |
| 132 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 133 | /* close is called by the peer when it has gone away. |
| 134 | ** we are not allowed to make any further calls on the |
| 135 | ** peer once our close method is called. |
| 136 | */ |
| 137 | void (*close)(asocket *s); |
| 138 | |
Benoit Goby | 9470c2f | 2013-02-20 15:04:53 -0800 | [diff] [blame] | 139 | /* A socket is bound to atransport */ |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 140 | atransport *transport; |
| 141 | }; |
| 142 | |
| 143 | |
| 144 | /* the adisconnect structure is used to record a callback that |
| 145 | ** will be called whenever a transport is disconnected (e.g. by the user) |
| 146 | ** this should be used to cleanup objects that depend on the |
| 147 | ** transport (e.g. remote sockets, listeners, etc...) |
| 148 | */ |
| 149 | struct adisconnect |
| 150 | { |
| 151 | void (*func)(void* opaque, atransport* t); |
| 152 | void* opaque; |
| 153 | adisconnect* next; |
| 154 | adisconnect* prev; |
| 155 | }; |
| 156 | |
| 157 | |
| 158 | /* a transport object models the connection to a remote device or emulator |
| 159 | ** there is one transport per connected device/emulator. a "local transport" |
| 160 | ** connects through TCP (for the emulator), while a "usb transport" through |
| 161 | ** USB (for real devices) |
| 162 | ** |
| 163 | ** note that kTransportHost doesn't really correspond to a real transport |
| 164 | ** object, it's a special value used to indicate that a client wants to |
| 165 | ** connect to a service implemented within the ADB server itself. |
| 166 | */ |
| 167 | typedef enum transport_type { |
| 168 | kTransportUsb, |
| 169 | kTransportLocal, |
| 170 | kTransportAny, |
| 171 | kTransportHost, |
| 172 | } transport_type; |
| 173 | |
Benoit Goby | d5fcafa | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 174 | #define TOKEN_SIZE 20 |
| 175 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 176 | struct atransport |
| 177 | { |
| 178 | atransport *next; |
| 179 | atransport *prev; |
| 180 | |
| 181 | int (*read_from_remote)(apacket *p, atransport *t); |
| 182 | int (*write_to_remote)(apacket *p, atransport *t); |
| 183 | void (*close)(atransport *t); |
| 184 | void (*kick)(atransport *t); |
| 185 | |
| 186 | int fd; |
| 187 | int transport_socket; |
| 188 | fdevent transport_fde; |
| 189 | int ref_count; |
| 190 | unsigned sync_token; |
| 191 | int connection_state; |
Benoit Goby | d5fcafa | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 192 | int online; |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 193 | transport_type type; |
| 194 | |
| 195 | /* usb handle or socket fd as needed */ |
| 196 | usb_handle *usb; |
| 197 | int sfd; |
| 198 | |
| 199 | /* used to identify transports for clients */ |
| 200 | char *serial; |
| 201 | char *product; |
Scott Anderson | e82c2db | 2012-05-25 14:10:02 -0700 | [diff] [blame] | 202 | char *model; |
| 203 | char *device; |
Scott Anderson | e109d26 | 2012-04-20 11:21:14 -0700 | [diff] [blame] | 204 | char *devpath; |
Stefan Hilzinger | d9d1ca4 | 2010-04-26 10:17:43 +0100 | [diff] [blame] | 205 | int adb_port; // Use for emulators (local transport) |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 206 | |
| 207 | /* a list of adisconnect callbacks called when the transport is kicked */ |
| 208 | int kicked; |
| 209 | adisconnect disconnects; |
Benoit Goby | d5fcafa | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 210 | |
| 211 | void *key; |
| 212 | unsigned char token[TOKEN_SIZE]; |
| 213 | fdevent auth_fde; |
| 214 | unsigned failed_auth_attempts; |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 215 | }; |
| 216 | |
| 217 | |
| 218 | /* A listener is an entity which binds to a local port |
| 219 | ** and, upon receiving a connection on that port, creates |
| 220 | ** an asocket to connect the new local connection to a |
| 221 | ** specific remote service. |
| 222 | ** |
| 223 | ** TODO: some listeners read from the new connection to |
| 224 | ** determine what exact service to connect to on the far |
| 225 | ** side. |
| 226 | */ |
| 227 | struct alistener |
| 228 | { |
| 229 | alistener *next; |
| 230 | alistener *prev; |
| 231 | |
| 232 | fdevent fde; |
| 233 | int fd; |
| 234 | |
| 235 | const char *local_name; |
| 236 | const char *connect_to; |
| 237 | atransport *transport; |
| 238 | adisconnect disconnect; |
| 239 | }; |
| 240 | |
| 241 | |
| 242 | void print_packet(const char *label, apacket *p); |
| 243 | |
David 'Digit' Turner | 818d641 | 2013-12-13 14:09:44 +0100 | [diff] [blame] | 244 | asocket *find_local_socket(unsigned local_id, unsigned remote_id); |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 245 | void install_local_socket(asocket *s); |
| 246 | void remove_socket(asocket *s); |
| 247 | void close_all_sockets(atransport *t); |
| 248 | |
| 249 | #define LOCAL_CLIENT_PREFIX "emulator-" |
| 250 | |
| 251 | asocket *create_local_socket(int fd); |
| 252 | asocket *create_local_service_socket(const char *destination); |
| 253 | |
| 254 | asocket *create_remote_socket(unsigned id, atransport *t); |
| 255 | void connect_to_remote(asocket *s, const char *destination); |
| 256 | void connect_to_smartsocket(asocket *s); |
| 257 | |
| 258 | void fatal(const char *fmt, ...); |
| 259 | void fatal_errno(const char *fmt, ...); |
| 260 | |
| 261 | void handle_packet(apacket *p, atransport *t); |
| 262 | void send_packet(apacket *p, atransport *t); |
| 263 | |
Alexey Tarasov | 3166410 | 2009-10-22 02:55:00 +1100 | [diff] [blame] | 264 | void get_my_path(char *s, size_t maxLen); |
Stefan Hilzinger | a84a42e | 2010-04-19 12:21:12 +0100 | [diff] [blame] | 265 | int launch_server(int server_port); |
| 266 | int adb_main(int is_daemon, int server_port); |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 267 | |
| 268 | |
| 269 | /* transports are ref-counted |
| 270 | ** get_device_transport does an acquire on your behalf before returning |
| 271 | */ |
| 272 | void init_transport_registration(void); |
Scott Anderson | 2ca3e6b | 2012-05-30 18:11:27 -0700 | [diff] [blame] | 273 | int list_transports(char *buf, size_t bufsize, int long_listing); |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 274 | void update_transports(void); |
| 275 | |
| 276 | asocket* create_device_tracker(void); |
| 277 | |
| 278 | /* Obtain a transport from the available transports. |
| 279 | ** If state is != CS_ANY, only transports in that state are considered. |
| 280 | ** If serial is non-NULL then only the device with that serial will be chosen. |
| 281 | ** If no suitable transport is found, error is set. |
| 282 | */ |
| 283 | atransport *acquire_one_transport(int state, transport_type ttype, const char* serial, char **error_out); |
| 284 | void add_transport_disconnect( atransport* t, adisconnect* dis ); |
| 285 | void remove_transport_disconnect( atransport* t, adisconnect* dis ); |
| 286 | void run_transport_disconnects( atransport* t ); |
| 287 | void kick_transport( atransport* t ); |
| 288 | |
| 289 | /* initialize a transport object's func pointers and state */ |
Stefan Hilzinger | d9d1ca4 | 2010-04-26 10:17:43 +0100 | [diff] [blame] | 290 | #if ADB_HOST |
| 291 | int get_available_local_transport_index(); |
| 292 | #endif |
Mike Lockwood | 2f38b69 | 2009-08-24 15:58:40 -0700 | [diff] [blame] | 293 | int init_socket_transport(atransport *t, int s, int port, int local); |
Mike Lockwood | 95b837d | 2009-08-08 12:37:44 -0400 | [diff] [blame] | 294 | void init_usb_transport(atransport *t, usb_handle *usb, int state); |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 295 | |
| 296 | /* for MacOS X cleanup */ |
| 297 | void close_usb_devices(); |
| 298 | |
| 299 | /* cause new transports to be init'd and added to the list */ |
Benoit Goby | 1c45ee9 | 2013-03-29 18:22:36 -0700 | [diff] [blame] | 300 | int register_socket_transport(int s, const char *serial, int port, int local); |
Mike Lockwood | 74d7ff8 | 2009-10-11 23:04:18 -0400 | [diff] [blame] | 301 | |
Mike Lockwood | cbbe79a | 2010-05-24 10:44:35 -0400 | [diff] [blame] | 302 | /* these should only be used for the "adb disconnect" command */ |
Mike Lockwood | 74d7ff8 | 2009-10-11 23:04:18 -0400 | [diff] [blame] | 303 | void unregister_transport(atransport *t); |
Mike Lockwood | cbbe79a | 2010-05-24 10:44:35 -0400 | [diff] [blame] | 304 | void unregister_all_tcp_transports(); |
Mike Lockwood | 74d7ff8 | 2009-10-11 23:04:18 -0400 | [diff] [blame] | 305 | |
Scott Anderson | e109d26 | 2012-04-20 11:21:14 -0700 | [diff] [blame] | 306 | void register_usb_transport(usb_handle *h, const char *serial, const char *devpath, unsigned writeable); |
Mike Lockwood | 95b837d | 2009-08-08 12:37:44 -0400 | [diff] [blame] | 307 | |
| 308 | /* this should only be used for transports with connection_state == CS_NOPERM */ |
| 309 | void unregister_usb_transport(usb_handle *usb); |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 310 | |
Mike Lockwood | 74d7ff8 | 2009-10-11 23:04:18 -0400 | [diff] [blame] | 311 | atransport *find_transport(const char *serial); |
Stefan Hilzinger | d9d1ca4 | 2010-04-26 10:17:43 +0100 | [diff] [blame] | 312 | #if ADB_HOST |
| 313 | atransport* find_emulator_transport_by_adb_port(int adb_port); |
| 314 | #endif |
Mike Lockwood | 74d7ff8 | 2009-10-11 23:04:18 -0400 | [diff] [blame] | 315 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 316 | int service_to_fd(const char *name); |
| 317 | #if ADB_HOST |
| 318 | asocket *host_service_to_socket(const char* name, const char *serial); |
| 319 | #endif |
| 320 | |
| 321 | #if !ADB_HOST |
| 322 | int init_jdwp(void); |
| 323 | asocket* create_jdwp_service_socket(); |
| 324 | asocket* create_jdwp_tracker_service_socket(); |
| 325 | int create_jdwp_connection_fd(int jdwp_pid); |
| 326 | #endif |
| 327 | |
David 'Digit' Turner | 2525869 | 2013-03-21 21:07:42 +0100 | [diff] [blame] | 328 | int handle_forward_request(const char* service, transport_type ttype, char* serial, int reply_fd); |
| 329 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 330 | #if !ADB_HOST |
| 331 | void framebuffer_service(int fd, void *cookie); |
Paul Lawrence | 982089d | 2014-12-03 15:31:57 -0800 | [diff] [blame] | 332 | // Allow enable-verity to write to system and vendor block devices |
Sami Tolvanen | 13449cd | 2015-01-02 13:30:50 +0000 | [diff] [blame] | 333 | int make_block_device_writable(const char* dev); |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 334 | void remount_service(int fd, void *cookie); |
Paul Lawrence | 982089d | 2014-12-03 15:31:57 -0800 | [diff] [blame] | 335 | void set_verity_enabled_state_service(int fd, void* cookie); |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 336 | #endif |
| 337 | |
| 338 | /* packet allocator */ |
| 339 | apacket *get_apacket(void); |
| 340 | void put_apacket(apacket *p); |
| 341 | |
| 342 | int check_header(apacket *p); |
| 343 | int check_data(apacket *p); |
| 344 | |
leozwang | cbf0267 | 2014-08-15 09:51:27 -0700 | [diff] [blame] | 345 | // Define it if you want to dump packets. |
| 346 | #define DEBUG_PACKETS 0 |
| 347 | |
Benoit Goby | d5fcafa | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 348 | #if !DEBUG_PACKETS |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 349 | #define print_packet(tag,p) do {} while (0) |
| 350 | #endif |
| 351 | |
John Michelau | c318833 | 2010-09-23 17:08:34 -0500 | [diff] [blame] | 352 | #if ADB_HOST_ON_TARGET |
| 353 | /* adb and adbd are coexisting on the target, so use 5038 for adb |
| 354 | * to avoid conflicting with adbd's usage of 5037 |
| 355 | */ |
| 356 | # define DEFAULT_ADB_PORT 5038 |
| 357 | #else |
| 358 | # define DEFAULT_ADB_PORT 5037 |
| 359 | #endif |
| 360 | |
Stefan Hilzinger | a84a42e | 2010-04-19 12:21:12 +0100 | [diff] [blame] | 361 | #define DEFAULT_ADB_LOCAL_TRANSPORT_PORT 5555 |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 362 | |
Xavier Ducrohet | a481d09 | 2009-05-21 17:47:43 -0700 | [diff] [blame] | 363 | #define ADB_CLASS 0xff |
| 364 | #define ADB_SUBCLASS 0x42 |
| 365 | #define ADB_PROTOCOL 0x1 |
Dima Zavin | 3fd82b8 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 366 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 367 | |
Mike Lockwood | cef31a0 | 2009-08-26 12:50:22 -0700 | [diff] [blame] | 368 | void local_init(int port); |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 369 | int local_connect(int port); |
Stefan Hilzinger | d9d1ca4 | 2010-04-26 10:17:43 +0100 | [diff] [blame] | 370 | int local_connect_arbitrary_ports(int console_port, int adb_port); |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 371 | |
| 372 | /* usb host/client interface */ |
| 373 | void usb_init(); |
| 374 | void usb_cleanup(); |
| 375 | int usb_write(usb_handle *h, const void *data, int len); |
| 376 | int usb_read(usb_handle *h, void *data, int len); |
| 377 | int usb_close(usb_handle *h); |
| 378 | void usb_kick(usb_handle *h); |
| 379 | |
| 380 | /* used for USB device detection */ |
Xavier Ducrohet | a09fbd1 | 2009-05-20 17:33:53 -0700 | [diff] [blame] | 381 | #if ADB_HOST |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 382 | int is_adb_interface(int vid, int pid, int usb_class, int usb_subclass, int usb_protocol); |
Xavier Ducrohet | a09fbd1 | 2009-05-20 17:33:53 -0700 | [diff] [blame] | 383 | #endif |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 384 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 385 | int adb_commandline(int argc, char **argv); |
| 386 | |
| 387 | int connection_state(atransport *t); |
| 388 | |
| 389 | #define CS_ANY -1 |
| 390 | #define CS_OFFLINE 0 |
| 391 | #define CS_BOOTLOADER 1 |
| 392 | #define CS_DEVICE 2 |
| 393 | #define CS_HOST 3 |
| 394 | #define CS_RECOVERY 4 |
Mike Lockwood | 95b837d | 2009-08-08 12:37:44 -0400 | [diff] [blame] | 395 | #define CS_NOPERM 5 /* Insufficient permissions to communicate with the device */ |
Doug Zongker | 447f061 | 2012-01-09 14:54:53 -0800 | [diff] [blame] | 396 | #define CS_SIDELOAD 6 |
Benoit Goby | 77e8e58 | 2013-01-15 12:36:47 -0800 | [diff] [blame] | 397 | #define CS_UNAUTHORIZED 7 |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 398 | |
| 399 | extern int HOST; |
JP Abgrall | 408fa57 | 2011-03-16 15:57:42 -0700 | [diff] [blame] | 400 | extern int SHELL_EXIT_NOTIFY_FD; |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 401 | |
Jeff Sharkey | 5d9d434 | 2014-05-26 18:30:43 -0700 | [diff] [blame] | 402 | typedef enum { |
| 403 | SUBPROC_PTY = 0, |
| 404 | SUBPROC_RAW = 1, |
| 405 | } subproc_mode; |
| 406 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 407 | #define CHUNK_SIZE (64*1024) |
| 408 | |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 409 | #if !ADB_HOST |
| 410 | #define USB_ADB_PATH "/dev/android_adb" |
| 411 | |
| 412 | #define USB_FFS_ADB_PATH "/dev/usb-ffs/adb/" |
| 413 | #define USB_FFS_ADB_EP(x) USB_FFS_ADB_PATH#x |
| 414 | |
| 415 | #define USB_FFS_ADB_EP0 USB_FFS_ADB_EP(ep0) |
| 416 | #define USB_FFS_ADB_OUT USB_FFS_ADB_EP(ep1) |
| 417 | #define USB_FFS_ADB_IN USB_FFS_ADB_EP(ep2) |
| 418 | #endif |
| 419 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 420 | int sendfailmsg(int fd, const char *reason); |
| 421 | int handle_host_request(char *service, transport_type ttype, char* serial, int reply_fd, asocket *s); |
| 422 | |
| 423 | #endif |