blob: a2077e8d18340066a2c11f7229326bc808990a94 [file] [log] [blame]
JP Abgrall408fa572011-03-16 15:57:42 -07001/*
2 * Copyright (C) 2011 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 __TRANSPORT_H
18#define __TRANSPORT_H
19
Dan Alberte9fca142015-02-18 18:03:26 -080020#include <sys/types.h>
21
Elliott Hughes7be29c82015-04-16 22:54:44 -070022#include <string>
Dan Albert76649012015-02-24 15:51:19 -080023
Elliott Hughes7be29c82015-04-16 22:54:44 -070024#include "adb.h"
Dan Albert630b9af2014-11-24 23:34:35 -080025
Dan Albertcc731cc2015-02-24 21:26:58 -080026#if ADB_TRACE
27void dump_hex(const unsigned char* ptr, size_t len);
28#endif
Dan Albert630b9af2014-11-24 23:34:35 -080029
Dan Albert76649012015-02-24 15:51:19 -080030/*
31 * Obtain a transport from the available transports.
32 * If state is != CS_ANY, only transports in that state are considered.
33 * If serial is non-NULL then only the device with that serial will be chosen.
34 * If no suitable transport is found, error is set.
35 */
36atransport* acquire_one_transport(int state, transport_type ttype,
Elliott Hughes7be29c82015-04-16 22:54:44 -070037 const char* serial, std::string* error_out);
Dan Albert76649012015-02-24 15:51:19 -080038void add_transport_disconnect(atransport* t, adisconnect* dis);
39void remove_transport_disconnect(atransport* t, adisconnect* dis);
40void kick_transport(atransport* t);
41void run_transport_disconnects(atransport* t);
42void update_transports(void);
43
44/* transports are ref-counted
45** get_device_transport does an acquire on your behalf before returning
46*/
47void init_transport_registration(void);
48int list_transports(char* buf, size_t bufsize, int long_listing);
49atransport* find_transport(const char* serial);
50
51void register_usb_transport(usb_handle* h, const char* serial,
52 const char* devpath, unsigned writeable);
53
54/* cause new transports to be init'd and added to the list */
55int register_socket_transport(int s, const char* serial, int port, int local);
56
57/* this should only be used for transports with connection_state == CS_NOPERM */
58void unregister_usb_transport(usb_handle* usb);
59
60/* these should only be used for the "adb disconnect" command */
61void unregister_transport(atransport* t);
62void unregister_all_tcp_transports();
63
64int check_header(apacket* p);
65int check_data(apacket* p);
66
67/* for MacOS X cleanup */
68void close_usb_devices();
69
70void send_packet(apacket* p, atransport* t);
71
72asocket* create_device_tracker(void);
73
JP Abgrall408fa572011-03-16 15:57:42 -070074#endif /* __TRANSPORT_H */