src/dps8/fnpuv.c
//
// Connection callback handler for dialup connections
//
Connection callback handler for dialup connections
Connection callback handler for dialup connections
static void on_new_connection (uv_stream_t * server, int status)
  {
    if (status < 0)
      {
        sim_printf ("[FNP emulation: New connection error %s]\n", uv_strerror (status));
        return;
      }
    uv_tcp_t * client = (uv_tcp_t *) malloc (sizeof (uv_tcp_t));
#if 0
    if (server->data)
      {
        uvClientData * p = (uvClientData *) server->data;
        struct t_line * linep = & fnpUnitData[p->fnpno].MState.line[p->lineno];
sim_printf ("slave connection to %d.%d\n", p->fnpno, p->lineno); 
        linep->client = client;
      }
#endif
    uv_tcp_init (loop, client);
    if (uv_accept (server, (uv_stream_t *) client) == 0)
      {
        if (server->data)
          {
            uvClientData * p = (uvClientData *) server->data;
            struct t_line * linep = & fnpUnitData[p->fnpno].MState.line[p->lineno];
#if 1
            if (linep->client)
              {
                uv_close ((uv_handle_t *) client, fuv_close_cb);
sim_printf ("[FNP emulation: dropping 2nd slave]\n");
                return;
              }
#endif
            linep->client = client;
          }
        struct sockaddr name;
        int namelen = sizeof (name);
        int ret = uv_tcp_getpeername (client, & name, & namelen);
        if (ret < 0)
          {
            sim_printf ("[FNP emulation: CONNECT; addr err %d]\n", ret);
          }
        else
          {
            struct sockaddr_in * p = (struct sockaddr_in *) & name;
            sim_printf ("[FNP emulation: CONNECT %s]\n", inet_ntoa (p -> sin_addr));
          }
        uvClientData * p = (uvClientData *) malloc (sizeof (uvClientData));
        if (! p)
          {
             sim_warn ("uvClientData malloc failed\n");
             return;
          }
        p -> assoc = false;
        p -> nPos = 0;
        if (! server->data)
          {
            p->telnetp = ltnConnect (client);
            if (! p->telnetp)
              {
                 sim_warn ("ltnConnect failed\n");
                 return;
              }
          }
        else
          {
            p->telnetp = NULL;
            uvClientData * q = (uvClientData *) server->data;
            p->fnpno = q->fnpno;
            p->lineno = q->lineno;
            p->assoc = true;
          }
        client->data = p;
        fnpuv_read_start (client);
        if (! server->data)
          fnpConnectPrompt (client);
        else
          {
            uvClientData * p = (uvClientData *) server->data;
            struct t_line * linep = & fnpUnitData[p->fnpno].MState.line[p->lineno];
            linep->accept_new_terminal = true;
            linep->was_CR = false;
            linep->inputBufferSize = 0;
            linep->ctrlStrIdx = 0;
            linep->breakAll = false;
            linep->handleQuit = false;
            linep->echoPlex = false;
            linep->crecho = false;
            linep->lfecho = false;
            linep->tabecho = false;
            linep->replay = false;
            linep->polite = false;
            linep->prefixnl = false;
            linep->eight_bit_out = false;
            linep->eight_bit_in = false;
            linep->odd_parity = false;
            linep->output_flow_control = false;
            linep->input_flow_control = false;
            linep->block_xfer_in_frame_sz = 0;
            linep->block_xfer_out_frame_sz = 0;
            memset (linep->delay_table, 0, sizeof (linep->delay_table));
            linep->inputSuspendLen = 0;
            memset (linep->inputSuspendStr, 0, sizeof (linep->inputSuspendStr));
            linep->inputResumeLen = 0;
            memset (linep->inputResumeStr, 0, sizeof (linep->inputResumeStr));
            linep->outputSuspendLen = 0;
            memset (linep->outputSuspendStr, 0, sizeof (linep->outputSuspendStr));
            linep->outputResumeLen = 0;
            memset (linep->outputResumeStr, 0, sizeof (linep->outputResumeStr));
            linep->frame_begin = 0;
            linep->frame_end = 0;
            memset (linep->echnego, 0, sizeof (linep->echnego));
            linep->echnego_len = 0;
            linep->line_break = false;
          }
      }
    else
      {
        uv_close ((uv_handle_t *) client, fuv_close_cb);
      }
  }
static void on_new_connection ( uv_stream_t * server , int status ) { if ( status < 0 ) { sim_printf ( " \n " , uv_strerror ( status ) ) ; return ; } uv_tcp_t * client = ( uv_tcp_t * ) malloc ( sizeof ( uv_tcp_t ) ) ; #if 0 if ( server -> data ) { uvClientData * p = ( uvClientData * ) server -> data ; struct t_line * linep = & fnpUnitData [ p -> fnpno ] . MState . line [ p -> lineno ] ; sim_printf ( " \n " , p -> fnpno , p -> lineno ) ; linep -> client = client ; } #endif uv_tcp_init ( loop , client ) ; if ( uv_accept ( server , ( uv_stream_t * ) client ) == 0 ) { if ( server -> data ) { uvClientData * p = ( uvClientData * ) server -> data ; struct t_line * linep = & fnpUnitData [ p -> fnpno ] . MState . line [ p -> lineno ] ; #if 1 if ( linep -> client ) { uv_close ( ( uv_handle_t * ) client , fuv_close_cb ) ; sim_printf ( " \n " ) ; return ; } #endif linep -> client = client ; } struct sockaddr name ; int namelen = sizeof ( name ) ; int ret = uv_tcp_getpeername ( client , & name , & namelen ) ; if ( ret < 0 ) { sim_printf ( " \n " , ret ) ; } else { struct sockaddr_in * p = ( struct sockaddr_in * ) & name ; sim_printf ( " \n " , inet_ntoa ( p -> sin_addr ) ) ; } uvClientData * p = ( uvClientData * ) malloc ( sizeof ( uvClientData ) ) ; if ( ! p ) { sim_warn ( " \n " ) ; return ; } p -> assoc = false ; p -> nPos = 0 ; if ( ! server -> data ) { p -> telnetp = ltnConnect ( client ) ; if ( ! p -> telnetp ) { sim_warn ( " \n " ) ; return ; } } else { p -> telnetp = NULL ; uvClientData * q = ( uvClientData * ) server -> data ; p -> fnpno = q -> fnpno ; p -> lineno = q -> lineno ; p -> assoc = true ; } client -> data = p ; fnpuv_read_start ( client ) ; if ( ! server -> data ) fnpConnectPrompt ( client ) ; else { uvClientData * p = ( uvClientData * ) server -> data ; struct t_line * linep = & fnpUnitData [ p -> fnpno ] . MState . line [ p -> lineno ] ; linep -> accept_new_terminal = true ; linep -> was_CR = false ; linep -> inputBufferSize = 0 ; linep -> ctrlStrIdx = 0 ; linep -> breakAll = false ; linep -> handleQuit = false ; linep -> echoPlex = false ; linep -> crecho = false ; linep -> lfecho = false ; linep -> tabecho = false ; linep -> replay = false ; linep -> polite = false ; linep -> prefixnl = false ; linep -> eight_bit_out = false ; linep -> eight_bit_in = false ; linep -> odd_parity = false ; linep -> output_flow_control = false ; linep -> input_flow_control = false ; linep -> block_xfer_in_frame_sz = 0 ; linep -> block_xfer_out_frame_sz = 0 ; memset ( linep -> delay_table , 0 , sizeof ( linep -> delay_table ) ) ; linep -> inputSuspendLen = 0 ; memset ( linep -> inputSuspendStr , 0 , sizeof ( linep -> inputSuspendStr ) ) ; linep -> inputResumeLen = 0 ; memset ( linep -> inputResumeStr , 0 , sizeof ( linep -> inputResumeStr ) ) ; linep -> outputSuspendLen = 0 ; memset ( linep -> outputSuspendStr , 0 , sizeof ( linep -> outputSuspendStr ) ) ; linep -> outputResumeLen = 0 ; memset ( linep -> outputResumeStr , 0 , sizeof ( linep -> outputResumeStr ) ) ; linep -> frame_begin = 0 ; linep -> frame_end = 0 ; memset ( linep -> echnego , 0 , sizeof ( linep -> echnego ) ) ; linep -> echnego_len = 0 ; linep -> line_break = false ; } } else { uv_close ( ( uv_handle_t * ) client , fuv_close_cb ) ; } }
Connection callback handler for dialup connections
Connection callback handler for dialup connections
// error! // if server->data is non-null, this is a slave server; else a dialup // server // if server->data is non-null, this is a slave server; else a dialup // server // Slave servers only handle a single connection at a time // dialup connections are routed through libtelent //linep->listen = false;