static int tcp_chr_new_client(Chardev *chr, QIOChannelSocket *sioc) { SocketChardev *s = SOCKET_CHARDEV(chr); if (s->ioc != NULL) { return -1; } s->ioc = QIO_CHANNEL(sioc); object_ref(OBJECT(sioc)); s->sioc = sioc; object_ref(OBJECT(sioc)); qio_channel_set_blocking(s->ioc, false, NULL); if (s->do_nodelay) { qio_channel_set_delay(s->ioc, false); } if (s->listen_tag) { g_source_remove(s->listen_tag); s->listen_tag = 0; } if (s->tls_creds) { tcp_chr_tls_init(chr); } else { if (s->do_telnetopt) { tcp_chr_telnet_init(chr); } else { tcp_chr_connect(chr); } } return 0; }
static gboolean tcp_chr_telnet_init_io(QIOChannel *ioc, GIOCondition cond G_GNUC_UNUSED, gpointer user_data) { TCPChardevTelnetInit *init = user_data; ssize_t ret; ret = qio_channel_write(ioc, init->buf, init->buflen, NULL); if (ret < 0) { if (ret == QIO_CHANNEL_ERR_BLOCK) { ret = 0; } else { tcp_chr_disconnect(init->chr); return FALSE; } } init->buflen -= ret; if (init->buflen == 0) { tcp_chr_connect(init->chr); return FALSE; } memmove(init->buf, init->buf + ret, init->buflen); return TRUE; }
static void tcp_chr_tls_handshake(QIOTask *task, gpointer user_data) { Chardev *chr = user_data; SocketChardev *s = user_data; if (qio_task_propagate_error(task, NULL)) { tcp_chr_disconnect(chr); } else { if (s->do_telnetopt) { tcp_chr_telnet_init(chr); } else { tcp_chr_connect(chr); } } }
static void tcp_chr_tls_handshake(QIOTask *task, gpointer user_data) { Chardev *chr = user_data; SocketChardev *s = user_data; if (qio_task_propagate_error(task, NULL)) { tcp_chr_disconnect(chr); } else { /* tn3270 does not support TLS yet */ if (s->do_telnetopt && !s->is_tn3270) { tcp_chr_telnet_init(chr); } else { tcp_chr_connect(chr); } } }