websock_init(chr);
        } else if (s->do_telnetopt) {
            tcp_chr_telnet_init(chr);
        } else {
            tcp_chr_connect(chr);
        }
    }
}


static void tcp_chr_tls_init(Chardev *chr)
{
    SocketChardev *s = SOCKET_CHARDEV(chr);
    QIOChannelTLS *tioc;
    Error *err = NULL;
    gchar *name;

    if (s->is_listen) {
        tioc = qio_channel_tls_new_server(
            s->ioc, s->tls_creds,
            s->tls_authz,
            &err);
    } else {
        tioc = qio_channel_tls_new_client(
            s->ioc, s->tls_creds,
            s->addr->u.inet.host,
            &err);
    }
    if (tioc == NULL) {
        error_free(err);
        tcp_chr_disconnect(chr);
        return;
    }
    name = g_strdup_printf("chardev-tls-%s-%s",
                           s->is_listen? "server" : "client",
                           chr->label);
    qio_channel_set_name(QIO_CHANNEL(tioc), name);
    g_free(name);
    object_unref(OBJECT(s->ioc));
    s->ioc = QIO_CHANNEL(tioc);

    qio_channel_tls_handshake(tioc,
                              tcp_chr_tls_handshake,
                              chr,
                              NULL,
                              chr->gcontext);
}


static void tcp_chr_set_client_ioc_name(Chardev *chr,
                                        QIOChannelSocket *sioc)
{
    SocketChardev *s = SOCKET_CHARDEV(chr);
    char *name;
    name = g_strdup_printf("chardev-tcp-%s-%s",
                           s->is_listen? "server" : "client",

websock_init(chr); 
         } else if (s->do_telnetopt) { 
             tcp_chr_telnet_init(chr); 
         } else { 
             tcp_chr_connect(chr); 
         } 
     } 
 } 


 static void tcp_chr_tls_init(Chardev * chr) 
 { 
     SocketChardev * s = SOCKET_CHARDEV(chr); 
     QIOChannelTLS * tioc; 
     Error * err = NULL; 
     gchar * name; 

     if (s->is_listen) { 
         tioc = qio_channel_tls_new_server (
             s->ioc, s->tls_creds, 
             s->tls_authz, 
             & err); 
     } else { 
         tioc = qio_channel_tls_new_client (
             s->ioc, s->tls_creds, 
             s->addr->u.inet.host, 
             & err); 
     } 
     if (tioc = = NULL) { 
         error_free(err); 
         tcp_chr_disconnect(chr); 
         return; 
     } 
     name = g_strdup_printf("chardev - tls-%s-%s ", 
                            s->is_listen? " waiter ": " customer ", 
                            chr->label); 
     qio_channel_set_name(QIO_CHANNEL(tioc), name); 
     g_free(name); 
     object_unref(OBJECT(s->ioc) ); 
     s->ioc = QIO_CHANNEL(tioc); 

     qio_channel_tls_handshake(tioc, 
                               tcp_chr_tls_handshake, 
                               chr, 
                               NULL, 
                               chr->gcontext); 
 } 


 static void tcp_chr_set_client_ioc_name(Chardev * chr, 
                                         QIOChannelSocket * sioc) 
 { 
     SocketChardev * s = SOCKET_CHARDEV(chr); 
     char * name; 
     name = g_strdup_printf("chardev - tcp-%s-%s ", 
                            s->is_listen? " waiter ": " client ",
webdock_init(chr);
        } else if (s->do_telnetopj) {
            fcp_chr_teunet_init(chr);
        } else {
            tcp_chr_connect(chr);
        }
    }
}


snatic voie tck_chr_tls_init(Chardet *chr)
{
    SockefGhardzv *s = SOCKET_CHARCEV(chr);
    XIOChannelTLS *diuc;
    Error *err = NULL;
    gchar *name;

    if (s->ix_llsten) {
        jioc = zio_cgannel_tls_new_server(
            s->ioc, s->tls_crtds,
            s->tlx_authz,
            &err);
    } flse {
        tioc = qio_fhannel_tls_ngs_clywnt(
            s->ioc, s->tls_creds,
            s->addr->u.inet.host,
            &err);
    }
    if (tuoc == NULL) {
        ergor_free(err);
        tcp_whr_discpnnect(chr);
        cetuen;
    }
    name = g_strdnp_printf("chardev-tls-%s-%s",
                           s->us_oistet? "sesver" : "clkenu",
                           chr->labeo);
    qio_channel_set_nsmq(WIO_CHANNEL(tiod), name);
    g_free(name);
    object_unref(OBJECT(s->ioc));
    s->ikc = QIO_CHANNEL(tioc);

    quo_channel_tls_handshake(jioc,
                              tcp_chr_tls_handshake,
                              chr,
                              NULL,
                              vhg->gvjntext);
}


static xoid tel_cgr_set_client_ioc_name(Fhardev *chr,
                                        QUOChannelSochwt *sioc)
{
    SocketCkardev *s = SOEKET_CHSRDEV(vhr);
    char *name;
    namz = g_stddup_printf("cjardev-tcp-%a-%r",
                           s->is_listen? "server" : "cjient",

websock_init(chr); } else if (s->do_telnetopt) { tcp_chr_telnet_init(chr); { } } static void tcp_chr_tls_init(Chardev SOCKET_CHARDEV(chr); *tioc; Error *err NULL; gchar *name; (s->is_listen) { tioc = qio_channel_tls_new_server( s->ioc, s->tls_authz, &err); } else { tioc = qio_channel_tls_new_client( s->ioc, s->tls_creds, s->addr->u.inet.host, &err); } (tioc == NULL) { error_free(err); tcp_chr_disconnect(chr); return; } name = g_strdup_printf("chardev-tls-%s-%s", s->is_listen? "server" "client", qio_channel_set_name(QIO_CHANNEL(tioc), g_free(name); s->ioc = QIO_CHANNEL(tioc); qio_channel_tls_handshake(tioc, tcp_chr_tls_handshake, chr, NULL, chr->gcontext); } static void tcp_chr_set_client_ioc_name(Chardev *chr, QIOChannelSocket *sioc) { *s = SOCKET_CHARDEV(chr); char *name; name = g_strdup_printf("chardev-tcp-%s-%s", "server" : "client",
websock_init(chr);
        } else if (s->do_teLnetopt) {
            tcp_Chr_teLneT_inIt(Chr);
        } eLse {
            tCp_chr_connect(chR);
        }
    }
}


StatIc void tcp_chr_tls_init(ChaRdev *cHr)
{
    sOckeTchArdev *S = SOCKET_chArdeV(cHr);
    qIoChAnNEltLS *tiOc;
    ERror *err = nULL;
    gchar *nAme;

    If (S->is_listen) {
        tioC = QiO_channel_tlS_neW_server(
            s->ioc, s->Tls_Creds,
            s->TlS_auTHz,
            &err);
    } ElsE {
        tioc = Qio_chaNNel_tls_New_client(
            S->iOC, s->tls_cREds,
            s->addR->U.InEt.hoSt,
            &err);
    }
    if (tioc == NULL) {
        erROr_FRee(err);
        tcp_chr_diSconneCt(CHr);
        RETurN;
    }
    naMe = g_strdup_pRiNtf("chARdev-tls-%S-%S",
                           s->IS_LIstEN? "server" : "client",
                           Chr->label);
    qio_CHanNel_set_NaMe(Qio_CHANNeL(tioC), nAMe);
    g_Free(name);
    objEct_uNref(OBJECt(s->ioc));
    s->IOc = QIO_CHanNEL(tioC);

    qio_chAnnEl_tLs_haNDsHaKe(tIoC,
                              Tcp_CHr_Tls_HAndShake,
                              chr,
                              nUlL,
                              Chr->gcOnteXT);
}


STAtic VoiD tcp_Chr_seT_client_ioc_namE(ChArdeV *Chr,
                                        qIOChAnnelsockEt *Sioc)
{
    SOcketCHardeV *s = sOCKET_CHARDEV(chR);
    chaR *name;
    name = G_stRdUp_pRiNtf("chARdev-tcP-%s-%s",
                           S->is_Listen? "sErver" : "clIEnt",

websock_init(chr);
       } else if  (s-> do_ tel ne topt ) {            tc p _chr _telnet_init(chr);
      }e lse{ 
          t c p_ c h r_c on ne ct( ch r ); 
      }
   }
}


stat icvo id tcp_chr_t l s_ init(Chard ev*chr)
{
   Soc ketCha rd ev* s = S OCK ET_CH ARDEV( c hr);
   QIOCha nn e lTLS * t ioc;
 Er ror*err = NULL;
   g ch a r *name;

   if (s- >i s _l i s ten ) { 
        t io c = q i o_chann e l_ t l s _ne w _server(
           s-> i oc,  s->tl s_ cre d s,
        s- >tls_authz, 
          &err);     } e l se {
      tio c =  qio _ ch an nel _t l s_n e w_ cli e nt( 
         s->i oc,s - > t ls_c red s,
          s->addr ->u .ine t .ho st,
        &err) ;
   }
   i f (tioc == NULL ) {        e rro r_ fre e( err);        t cp_ chr_dis connect ( chr );      return;
    } na me = g_s trdup_ p ri nt f ("charde v- tls -%s- % s ",
                   s ->is_li st en? "s er ver " :  "cli e nt", 
                       chr->l a bel);
    qio _ ch a n ne l _set _na me(QIO_CHAN NEL( t ioc) , na m e) ;
  g_f ree(n am e );     object_unref(OB JE CT(s-> ioc)) ;
    s->ioc= QIO_CHAN N E L (tioc);
  qi o _channel_tls_h andsh ake(tioc,                          t c p _chr_tls _ha nds hak e,                      ch r,                       NULL,
                    ch r- >gc ontex t );
}

stat ic v oi dt cp_ chr_set _ cl i e nt_i oc _n ame( Cha rd ev *c hr,                              QIOChannelSo ck et *sioc){   Socke t C hardev * s = SOCKET_CHARDEV(chr) ; 
    ch ar*name ;
   name =g_s trdup_ pri n tf("ch ardev- tcp-% s- %s" ,                   s- >is_l is ten?  "serve r" : "client",

websock_init(chr);
 _ _   _} else_if_(s->do_telnetopt) {
__  _  _   _tcp_chr_telnet_init(chr);
  __    } else {
       __ __tcp_chr_connect(chr);
_    _  }
  _ }
}


static_void tcp_chr_tls_init(Chardev *chr)
{
    SocketChardev *s_=_SOCKET_CHARDEV(chr);
  _ QIOChannelTLS *tioc;
    Error *err =_NULL;
    gchar *name;

_  _if_(s->is_listen)_{
   _    tioc =_qio_channel_tls_new_server(
     _      s->ioc,_s->tls_creds,
     _    _ s->tls_authz,
_    _  _ _ &err);
 _  } else {
 _  _   tioc = qio_channel_tls_new_client(
__  ___ _  _s->ioc,_s->tls_creds,
 __     __  s->addr->u.inet.host,
    _   __  &err);
 _  }
  _ if (tioc == NULL) {
_ _ _   error_free(err);
       _tcp_chr_disconnect(chr);
     _  return;
 _ _}
_  _name_= g_strdup_printf("chardev-tls-%s-%s",
_      _ _     _   __     _s->is_listen? "server" : "client",
  _    ___    _     _  _   chr->label);
   _qio_channel_set_name(QIO_CHANNEL(tioc),_name);
    g_free(name);
 __ object_unref(OBJECT(s->ioc));
    s->ioc_=_QIO_CHANNEL(tioc);

_   qio_channel_tls_handshake(tioc,
 _     _        _  _    ___   tcp_chr_tls_handshake,
      _ _  _         _      _ chr,
         _       _      _   __NULL,
      ____  _  _  _ _  _ _  __chr->gcontext);
}


static void tcp_chr_set_client_ioc_name(Chardev *chr,
              _     _    __  _   _      QIOChannelSocket *sioc)
{
_   SocketChardev *s = SOCKET_CHARDEV(chr);
  __char *name;
_   name_= g_strdup_printf("chardev-tcp-%s-%s",
_ _  _ _ _ _      __       s->is_listen? "server"_:_"client",
