Ejemplo n.º 1
0
static int DEFAULT_CC
xrdp_process_data_in(struct trans* self)
{
  struct xrdp_process* pro;

  DEBUG(("xrdp_process_data_in"));
  pro = (struct xrdp_process*)(self->callback_data);
  if (xrdp_process_loop(pro) != 0)
  {
    return 1;
  }
  return 0;
}
Ejemplo n.º 2
0
int APP_CC
xrdp_process_main_loop(struct xrdp_process* self)
{
  int robjs_count;
  int wobjs_count;
  int cont;
  int timeout;
  tbus robjs[32];
  tbus wobjs[32];
  tbus term_obj;
  tbus sck_obj;

  self->status = 1;
  self->session = libxrdp_init((long)self, self->sck);
  /* this callback function is in xrdp_wm.c */
  self->session->callback = callback;
  /* this function is just above */
  self->session->is_term = xrdp_is_term;
  g_tcp_set_non_blocking(self->sck);
  g_tcp_set_no_delay(self->sck);
  if (libxrdp_process_incomming(self->session) == 0)
  {
    term_obj = g_get_term_event();
    sck_obj = g_create_wait_obj_from_socket(self->sck, 0);
    cont = 1;
    while (cont)
    {
      /* build the wait obj list */
      timeout = -1;
      robjs_count = 0;
      wobjs_count = 0;
      robjs[robjs_count++] = term_obj;
      robjs[robjs_count++] = sck_obj;
      robjs[robjs_count++] = self->self_term_event;
      xrdp_wm_get_wait_objs(self->wm, robjs, &robjs_count,
                            wobjs, &wobjs_count, &timeout);
      /* wait */
      if (g_obj_wait(robjs, robjs_count, wobjs, wobjs_count, timeout) != 0)
      {
        /* error, should not get here */
        g_sleep(100);
      }
      if (g_is_wait_obj_set(term_obj)) /* term */
      {
        break;
      }
      if (g_is_wait_obj_set(self->self_term_event))
      {
        break;
      }
      if (g_is_wait_obj_set(sck_obj)) /* incomming client data */
      {
        if (xrdp_process_loop(self) != 0)
        {
          break;
        }
      }
      if (xrdp_wm_check_wait_objs(self->wm) != 0)
      {
        break;
      }
    }
    g_delete_wait_obj_from_socket(sck_obj);
    libxrdp_disconnect(self->session);
  }
  xrdp_process_mod_end(self);
  libxrdp_exit(self->session);
  self->session = 0;
  g_tcp_close(self->sck);
  self->status = -1;
  g_set_wait_obj(self->done_event);
  return 0;
}
Ejemplo n.º 3
0
static int DEFAULT_CC
xrdp_process_data_in(struct trans *self)
{
    struct xrdp_process *pro;
    struct stream *s;
    int len;

    DEBUG(("xrdp_process_data_in"));
    pro = (struct xrdp_process *)(self->callback_data);

    s = pro->server_trans->in_s;
    switch (pro->server_trans->extra_flags)
    {
        case 0:
            /* early in connection sequence, we're in this mode */
            if (xrdp_process_loop(pro, 0) != 0)
            {
                g_writeln("xrdp_process_data_in: "
                          "xrdp_process_loop failed");
                return 1;
            }
            if (pro->session->up_and_running)
            {
                pro->server_trans->header_size = 2;
                pro->server_trans->extra_flags = 1;
                init_stream(s, 0);
            }
            break;

        case 1:
            /* we got 2 bytes */
            if (s->p[0] == 3)
            {
                pro->server_trans->header_size = 4;
                pro->server_trans->extra_flags = 2;
            }
            else
            {
                if (s->p[1] & 0x80)
                {
                    pro->server_trans->header_size = 3;
                    pro->server_trans->extra_flags = 2;
                }
                else
                {
                    len = (tui8)(s->p[1]);
                    pro->server_trans->header_size = len;
                    pro->server_trans->extra_flags = 3;
                }
            }

            len = (int) (s->end - s->data);
            if (pro->server_trans->header_size > len)
            {
                /* not enough data read yet */
                break;
            }
            /* FALLTHROUGH */

        case 2:
            /* we have enough now to get the PDU bytes */
            len = libxrdp_get_pdu_bytes(s->p);
            if (len == -1)
            {
                g_writeln("xrdp_process_data_in: "
                          "xrdp_process_get_packet_bytes failed");
                return 1;
            }
            pro->server_trans->header_size = len;
            pro->server_trans->extra_flags = 3;

            len = (int) (s->end - s->data);
            if (pro->server_trans->header_size > len)
            {
                /* not enough data read yet */
                break;
            }
            /* FALLTHROUGH */

        case 3:
            /* the whole PDU is read in now process */
            s->p = s->data;
            if (xrdp_process_loop(pro, s) != 0)
            {
                g_writeln("xrdp_process_data_in: "
                          "xrdp_process_loop failed");
                return 1;
            }
            init_stream(s, 0);
            pro->server_trans->header_size = 2;
            pro->server_trans->extra_flags = 1;
            break;
    }
    return 0;
}