Ejemplo n.º 1
0
static int raw_closing(Plug plug, const char *error_msg, int error_code,
		       int calling_back)
{
    Raw raw = (Raw) plug;

    if (error_msg) {
        /* A socket error has occurred. */
        if (raw->s) {
            sk_close(raw->s);
            raw->s = NULL;
            notify_remote_exit(raw->frontend);
        }
        logevent(raw->frontend, error_msg);
        connection_fatal(raw->frontend, "%s", error_msg);
    } else {
        /* Otherwise, the remote side closed the connection normally. */
        if (!raw->sent_console_eof && from_backend_eof(raw->frontend)) {
            /*
             * The front end wants us to close the outgoing side of the
             * connection as soon as we see EOF from the far end.
             */
            if (!raw->sent_socket_eof) {
                if (raw->s)
                    sk_write_eof(raw->s);
                raw->sent_socket_eof= TRUE;
            }
        }
        raw->sent_console_eof = TRUE;
        raw_check_close(raw);
    }
    return 0;
}
Ejemplo n.º 2
0
static void sk_proxy_write_eof(Socket s)
{
  Proxy_Socket ps = (Proxy_Socket)s;

  if (ps->state != PROXY_STATE_ACTIVE) {
    ps->pending_eof = 1;
    return;
  }
  sk_write_eof(ps->sub_socket);
}
Ejemplo n.º 3
0
Archivo: proxy.c Proyecto: Riatre/PuTTY
static void sk_proxy_write_eof (Socket s)
{
    ProxySocket *ps = FROMFIELD(s, ProxySocket, sockvt);

    if (ps->state != PROXY_STATE_ACTIVE) {
        ps->pending_eof = 1;
	return;
    }
    sk_write_eof(ps->sub_socket);
}
Ejemplo n.º 4
0
static void sk_proxy_write_eof (Socket *s)
{
    ProxySocket *ps = container_of(s, ProxySocket, sock);

    if (ps->state != PROXY_STATE_ACTIVE) {
        ps->pending_eof = true;
	return;
    }
    sk_write_eof(ps->sub_socket);
}
Ejemplo n.º 5
0
/*
 * Call this when proxy negotiation is complete, so that this
 * socket can begin working normally.
 */
void proxy_activate(Proxy_Socket p)
{
  void *data;
  int len;
  long output_before, output_after;

  p->state = PROXY_STATE_ACTIVE;

  /* we want to ignore new receive events until we have sent
   * all of our buffered receive data.
   */
  sk_set_frozen(p->sub_socket, 1);

  /* how many bytes of output have we buffered? */
  output_before = bufchain_size(&p->pending_oob_output_data) +
                  bufchain_size(&p->pending_output_data);
  /* and keep track of how many bytes do not get sent. */
  output_after = 0;

  /* send buffered OOB writes */
  while (bufchain_size(&p->pending_oob_output_data) > 0) {
    bufchain_prefix(&p->pending_oob_output_data, &data, &len);
    output_after += sk_write_oob(p->sub_socket, data, len);
    bufchain_consume(&p->pending_oob_output_data, len);
  }

  /* send buffered normal writes */
  while (bufchain_size(&p->pending_output_data) > 0) {
    bufchain_prefix(&p->pending_output_data, &data, &len);
    output_after += sk_write(p->sub_socket, data, len);
    bufchain_consume(&p->pending_output_data, len);
  }

  /* if we managed to send any data, let the higher levels know. */
  if (output_after < output_before)
    plug_sent(p->plug, output_after);

  /* if we were asked to flush the output during
   * the proxy negotiation process, do so now.
   */
  if (p->pending_flush)
    sk_flush(p->sub_socket);

  /* if we have a pending EOF to send, send it */
  if (p->pending_eof)
    sk_write_eof(p->sub_socket);

  /* if the backend wanted the socket unfrozen, try to unfreeze.
   * our set_frozen handler will flush buffered receive data before
   * unfreezing the actual underlying socket.
   */
  if (!p->freeze)
    sk_set_frozen((Socket)p, 0);
}
Ejemplo n.º 6
0
/*
 * Send raw special codes. We only handle outgoing EOF here.
 */
static void raw_special(void *handle, Telnet_Special code)
{
    Raw raw = (Raw) handle;
    if (code == TS_EOF && raw->s) {
        sk_write_eof(raw->s);
        raw->sent_socket_eof= TRUE;
        raw_check_close(raw);
    }

    return;
}