Lines 46-51
Link Here
|
46 |
#if !defined(_WIN32) |
46 |
#if !defined(_WIN32) |
47 |
#include <sys/ioctl.h> |
47 |
#include <sys/ioctl.h> |
48 |
#include <termios.h> |
48 |
#include <termios.h> |
|
|
49 |
#include <unistd.h> |
49 |
#else |
50 |
#else |
50 |
#define _POSIX |
51 |
#define _POSIX |
51 |
#include <signal.h> |
52 |
#include <signal.h> |
Lines 125-130
Link Here
|
125 |
" acceptfd:<fd> (listen only)\n" |
126 |
" acceptfd:<fd> (listen only)\n" |
126 |
" forward --remove LOCAL remove specific forward socket connection\n" |
127 |
" forward --remove LOCAL remove specific forward socket connection\n" |
127 |
" forward --remove-all remove all forward socket connections\n" |
128 |
" forward --remove-all remove all forward socket connections\n" |
|
|
129 |
" ppp TTY [PARAMETER...] run PPP over USB\n" |
128 |
" reverse --list list all reverse socket connections from device\n" |
130 |
" reverse --list list all reverse socket connections from device\n" |
129 |
" reverse [--no-rebind] REMOTE LOCAL\n" |
131 |
" reverse [--no-rebind] REMOTE LOCAL\n" |
130 |
" reverse socket connection using:\n" |
132 |
" reverse socket connection using:\n" |
Lines 1011-1016
Link Here
|
1011 |
return 1; |
1013 |
return 1; |
1012 |
} |
1014 |
} |
1013 |
|
1015 |
|
|
|
1016 |
static int ppp(int argc, const char** argv) { |
1017 |
#if defined(_WIN32) |
1018 |
error_exit("adb %s not implemented on Win32", argv[0]); |
1019 |
__builtin_unreachable(); |
1020 |
#else |
1021 |
if (argc < 2) error_exit("usage: adb %s <adb service name> [ppp opts]", argv[0]); |
1022 |
|
1023 |
const char* adb_service_name = argv[1]; |
1024 |
std::string error_message; |
1025 |
int fd = adb_connect(adb_service_name, &error_message); |
1026 |
if (fd < 0) { |
1027 |
error_exit("could not open adb service %s: %s", adb_service_name, error_message.c_str()); |
1028 |
} |
1029 |
|
1030 |
pid_t pid = fork(); |
1031 |
if (pid == -1) { |
1032 |
perror_exit("fork failed"); |
1033 |
} |
1034 |
|
1035 |
if (pid == 0) { |
1036 |
// child side |
1037 |
int i; |
1038 |
|
1039 |
// copy args |
1040 |
const char** ppp_args = (const char**)alloca(sizeof(char*) * argc + 1); |
1041 |
ppp_args[0] = "pppd"; |
1042 |
for (i = 2 ; i < argc ; i++) { |
1043 |
//argv[2] and beyond become ppp_args[1] and beyond |
1044 |
ppp_args[i - 1] = argv[i]; |
1045 |
} |
1046 |
ppp_args[i-1] = nullptr; |
1047 |
|
1048 |
dup2(fd, STDIN_FILENO); |
1049 |
dup2(fd, STDOUT_FILENO); |
1050 |
adb_close(STDERR_FILENO); |
1051 |
adb_close(fd); |
1052 |
|
1053 |
execvp("pppd", (char* const*)ppp_args); |
1054 |
perror_exit("exec pppd failed"); |
1055 |
} |
1056 |
|
1057 |
// parent side |
1058 |
adb_close(fd); |
1059 |
return 0; |
1060 |
#endif /* !defined(_WIN32) */ |
1061 |
} |
1062 |
|
1014 |
static bool wait_for_device(const char* service, |
1063 |
static bool wait_for_device(const char* service, |
1015 |
std::optional<std::chrono::milliseconds> timeout = std::nullopt) { |
1064 |
std::optional<std::chrono::milliseconds> timeout = std::nullopt) { |
1016 |
std::vector<std::string> components = android::base::Split(service, "-"); |
1065 |
std::vector<std::string> components = android::base::Split(service, "-"); |
Lines 2025-2030
Link Here
|
2025 |
else if (!strcmp(argv[0], "logcat") || !strcmp(argv[0], "lolcat") || |
2074 |
else if (!strcmp(argv[0], "logcat") || !strcmp(argv[0], "lolcat") || |
2026 |
!strcmp(argv[0], "longcat")) { |
2075 |
!strcmp(argv[0], "longcat")) { |
2027 |
return logcat(argc, argv); |
2076 |
return logcat(argc, argv); |
|
|
2077 |
} else if (!strcmp(argv[0], "ppp")) { |
2078 |
return ppp(argc, argv); |
2028 |
} else if (!strcmp(argv[0], "start-server")) { |
2079 |
} else if (!strcmp(argv[0], "start-server")) { |
2029 |
std::string error; |
2080 |
std::string error; |
2030 |
const int result = adb_connect("host:start-server", &error); |
2081 |
const int result = adb_connect("host:start-server", &error); |