Lines Matching refs:t

162 void handle_online(atransport *t)  in handle_online()  argument
165 t->online = 1; in handle_online()
167 t->SetConnectionEstablished(true); in handle_online()
173 void handle_offline(atransport *t) in handle_offline() argument
175 if (t->GetConnectionState() == kCsOffline) { in handle_offline()
176 LOG(INFO) << t->serial_name() << ": already offline"; in handle_offline()
180 LOG(INFO) << t->serial_name() << ": offline"; in handle_offline()
186 t->SetConnectionState(kCsOffline); in handle_offline()
189 t->online = 0; in handle_offline()
193 close_all_sockets(t); in handle_offline()
195 t->RunDisconnects(); in handle_offline()
241 void send_ready(unsigned local, unsigned remote, atransport* t, uint32_t ack_bytes) { in send_ready() argument
247 if (t->SupportsDelayedAck()) { in send_ready()
253 send_packet(p, t); in send_ready()
256 static void send_close(unsigned local, unsigned remote, atransport *t) in send_close() argument
263 send_packet(p, t); in send_close()
290 void send_tls_request(atransport* t) { in send_tls_request() argument
296 send_packet(p, t); in send_tls_request()
299 void send_connect(atransport* t) { in send_connect() argument
307 cp->msg.arg1 = t->get_max_payload(); in send_connect()
320 send_packet(cp, t); in send_connect()
323 void parse_banner(const std::string& banner, atransport* t) { in parse_banner() argument
332 t->SetFeatures(""); in parse_banner()
346 t->product = value; in parse_banner()
348 t->model = value; in parse_banner()
350 t->device = value; in parse_banner()
352 t->SetFeatures(value); in parse_banner()
360 t->SetConnectionState(kCsBootloader); in parse_banner()
363 t->SetConnectionState(kCsDevice); in parse_banner()
366 t->SetConnectionState(kCsRecovery); in parse_banner()
369 t->SetConnectionState(kCsSideload); in parse_banner()
372 t->SetConnectionState(kCsRescue); in parse_banner()
375 t->SetConnectionState(kCsHost); in parse_banner()
379 static void handle_new_connection(atransport* t, apacket* p) { in handle_new_connection() argument
380 handle_offline(t); in handle_new_connection()
382 t->update_version(p->msg.arg0, p->msg.arg1); in handle_new_connection()
384 parse_banner(banner, t); in handle_new_connection()
387 handle_online(t); in handle_new_connection()
392 if (t->use_tls) { in handle_new_connection()
396 send_tls_request(t); in handle_new_connection()
399 handle_online(t); in handle_new_connection()
400 send_connect(t); in handle_new_connection()
402 send_auth_request(t); in handle_new_connection()
407 void handle_packet(apacket *p, atransport *t) in handle_packet() argument
418 handle_new_connection(t, p); in handle_packet()
421 t->use_tls = true; in handle_packet()
423 send_tls_request(t); in handle_packet()
424 adb_auth_tls_handshake(t); in handle_packet()
426 adbd_auth_tls_handshake(t); in handle_packet()
432 if (t->use_tls) { in handle_packet()
438 if (t->GetConnectionState() != kCsAuthorizing) { in handle_packet()
439 t->SetConnectionState(kCsAuthorizing); in handle_packet()
441 send_auth_response(p->payload.data(), p->msg.data_length, t); in handle_packet()
448 if (adbd_auth_verify(t->token, sizeof(t->token), signature, &auth_key)) { in handle_packet()
449 adbd_auth_verified(t); in handle_packet()
450 t->failed_auth_attempts = 0; in handle_packet()
451 t->auth_key = auth_key; in handle_packet()
452 adbd_notify_framework_connected_key(t); in handle_packet()
454 if (t->failed_auth_attempts++ > 256) std::this_thread::sleep_for(1s); in handle_packet()
455 send_auth_request(t); in handle_packet()
461 t->auth_key = std::string(p->payload.data()); in handle_packet()
462 adbd_auth_confirm_key(t); in handle_packet()
466 t->SetConnectionState(kCsOffline); in handle_packet()
467 handle_offline(t); in handle_packet()
474 if (!t->online || p->msg.arg0 == 0) { in handle_packet()
479 if (t->SupportsDelayedAck() != static_cast<bool>(send_bytes)) { in handle_packet()
481 << " (delayed acks = " << t->SupportsDelayedAck() << ")"; in handle_packet()
482 send_close(0, p->msg.arg0, t); in handle_packet()
497 if (!t->IsReverseConfigured(address.data())) { in handle_packet()
499 << t->serial_name(); in handle_packet()
502 asocket* s = create_local_service_socket(address, t); in handle_packet()
504 send_close(0, p->msg.arg0, t); in handle_packet()
508 s->peer = create_remote_socket(p->msg.arg0, t); in handle_packet()
511 if (t->SupportsDelayedAck()) { in handle_packet()
516 send_ready(s->id, s->peer->id, t, INITIAL_DELAYED_ACK_BYTES); in handle_packet()
519 send_ready(s->id, s->peer->id, t, 0); in handle_packet()
527 if (t->online && p->msg.arg0 != 0 && p->msg.arg1 != 0) { in handle_packet()
546 s->peer = create_remote_socket(p->msg.arg0, t); in handle_packet()
556 p->msg.arg1, s->peer->id, p->msg.arg1, t->serial.c_str()); in handle_packet()
562 send_close(p->msg.arg1, p->msg.arg0, t); in handle_packet()
568 if (t->online && p->msg.arg1 != 0) { in handle_packet()
581 if (p->msg.arg0 == 0 && s->peer && s->peer->transport != t) { in handle_packet()
583 t->serial.c_str(), s->peer->transport->serial.c_str()); in handle_packet()
592 if (t->online && p->msg.arg0 != 0 && p->msg.arg1 != 0) { in handle_packet()
1310 atransport* t = acquire_one_transport(type, serial, transport_id, nullptr, &error); in handle_host_request() local
1311 if (t != nullptr) { in handle_host_request()
1312 s->transport = t; in handle_host_request()
1317 WriteFdExactly(reply_fd, &t->id, sizeof(t->id)); in handle_host_request()
1360 atransport* t = in handle_host_request() local
1363 if (t != nullptr) { in handle_host_request()
1364 SendOkay(reply_fd, FeatureSetToString(t->features())); in handle_host_request()
1392 atransport* t = find_transport(address.c_str()); in handle_host_request() local
1393 if (t != nullptr) { in handle_host_request()
1394 kick_transport(t); in handle_host_request()
1410 t = find_transport(serial.c_str()); in handle_host_request()
1411 if (t == nullptr) { in handle_host_request()
1415 kick_transport(t); in handle_host_request()
1429 atransport* t = in handle_host_request() local
1432 if (t) { in handle_host_request()
1433 SendOkay(reply_fd, !t->serial.empty() ? t->serial : "unknown"); in handle_host_request()
1441 atransport* t = in handle_host_request() local
1444 if (t) { in handle_host_request()
1445 SendOkay(reply_fd, !t->devpath.empty() ? t->devpath : "unknown"); in handle_host_request()
1453 atransport* t = in handle_host_request() local
1456 if (t) { in handle_host_request()
1457 SendOkay(reply_fd, to_string(t->GetConnectionState())); in handle_host_request()
1479 atransport* t = s->transport ? s->transport in handle_host_request() local
1482 if (t != nullptr) { in handle_host_request()
1483 kick_transport(t, true); in handle_host_request()
1484 response = "reconnecting " + t->serial_name() + " [" + in handle_host_request()
1485 to_string(t->GetConnectionState()) + "]\n"; in handle_host_request()
1493 atransport* t = s->transport ? s->transport in handle_host_request() local
1496 if (!t) { in handle_host_request()
1501 if (t->Attach(&error)) { in handle_host_request()
1503 android::base::StringPrintf("%s attached", t->serial_name().c_str())); in handle_host_request()
1512 atransport* t = s->transport ? s->transport in handle_host_request() local
1515 if (!t) { in handle_host_request()
1528 if (t->Detach(&error)) { in handle_host_request()
1530 android::base::StringPrintf("%s detached", t->serial_name().c_str())); in handle_host_request()
1564 bool result = iterate_transports([](const atransport* t) { in update_transport_status() argument
1565 if (t->type == kTransportUsb && t->online != 1) { in update_transport_status()