コード例 #1
0
ファイル: chansrv.c プロジェクト: skdong/nfs-ovd
/* returns error */
	static int APP_CC
send_init_response_message(void)
{
	struct stream* s;

	log_message(&log_conf, LOG_LEVEL_DEBUG, "chansrv[send_init_response_message]: ");
	s = trans_get_out_s(g_con_trans, 8192);
	if (s == 0)
	{
		return 1;
	}
	out_uint32_le(s, 0); /* version */
	out_uint32_le(s, 8 + 8); /* size */
	out_uint32_le(s, 2); /* msg id */
	out_uint32_le(s, 8); /* size */
	s_mark_end(s);
	return trans_force_write(g_con_trans);
}
コード例 #2
0
ファイル: xrdp_mm.c プロジェクト: LawrenceK/xrdp
/* returns error
   data coming from client that need to go to channel handler */
int APP_CC
xrdp_mm_process_channel_data(struct xrdp_mm* self, tbus param1, tbus param2,
                             tbus param3, tbus param4)
{
  struct stream* s = (struct stream *)NULL;
  int rv = 0;
  int length = 0;
  int total_length = 0;
  int flags = 0;
  int id = 0;
  char * data = (char *)NULL;

  rv = 0;
  if ((self->chan_trans != 0) && self->chan_trans_up)
  {
    s = trans_get_out_s(self->chan_trans, 8192);
    if (s != 0)
    {
      id = LOWORD(param1);
      flags = HIWORD(param1);
      length = param2;
      data = (char*)param3;
      total_length = param4;
      if (total_length < length)
      {
        g_writeln("WARNING in xrdp_mm_process_channel_data(): total_len < length");
        total_length = length;
      }
      out_uint32_le(s, 0); /* version */
      out_uint32_le(s, 8 + 8 + 2 + 2 + 2 + 4 + length);
      out_uint32_le(s, 5); /* msg id */
      out_uint32_le(s, 8 + 2 + 2 + 2 + 4 + length);
      out_uint16_le(s, id);
      out_uint16_le(s, flags);
      out_uint16_le(s, length);
      out_uint32_le(s, total_length);
      out_uint8a(s, data, length);
      s_mark_end(s);
      rv = trans_force_write(self->chan_trans);
    }
  }

  return rv;
}
コード例 #3
0
ファイル: xrdp_mm.c プロジェクト: LawrenceK/xrdp
/* returns error
   send a list of channels to the channel handler */
static int APP_CC
xrdp_mm_trans_send_channel_setup(struct xrdp_mm* self, struct trans* trans)
{
  int index = 0;
  int chan_id = 0;
  int chan_flags = 0;
  int size = 0;
  struct stream* s = (struct stream *)NULL;
  char chan_name[256];

  g_memset(chan_name,0,sizeof(char) * 256);

  s = trans_get_out_s(trans, 8192);
  if (s == 0)
  {
    return 1;
  }
  s_push_layer(s, iso_hdr, 8);
  s_push_layer(s, mcs_hdr, 8);
  s_push_layer(s, sec_hdr, 2);
  index = 0;
  while (libxrdp_query_channel(self->wm->session, index, chan_name,
                               &chan_flags) == 0)
  {
    chan_id = libxrdp_get_channel_id(self->wm->session, chan_name);
    out_uint8a(s, chan_name, 8);
    out_uint16_le(s, chan_id);
    out_uint16_le(s, chan_flags);
    index++;
  }
  s_mark_end(s);
  s_pop_layer(s, sec_hdr);
  out_uint16_le(s, index);
  s_pop_layer(s, mcs_hdr);
  size = (int)(s->end - s->p);
  out_uint32_le(s, 3); /* msg id */
  out_uint32_le(s, size); /* msg size */
  s_pop_layer(s, iso_hdr);
  size = (int)(s->end - s->p);
  out_uint32_le(s, 0); /* version */
  out_uint32_le(s, size); /* block size */
  return trans_force_write(trans);
}
コード例 #4
0
ファイル: chansrv.c プロジェクト: eric011/xrdp
/* returns error */
static int APP_CC
send_channel_data_response_message(void)
{
    struct stream *s = (struct stream *)NULL;

    LOGM((LOG_LEVEL_DEBUG, "send_channel_data_response_message:"));
    s = trans_get_out_s(g_con_trans, 8192);

    if (s == 0)
    {
        return 1;
    }

    out_uint32_le(s, 0); /* version */
    out_uint32_le(s, 8 + 8); /* size */
    out_uint32_le(s, 6); /* msg id */
    out_uint32_le(s, 8); /* size */
    s_mark_end(s);
    return trans_force_write(g_con_trans);
}
コード例 #5
0
ファイル: chansrv.c プロジェクト: nrich/xrdp
/* returns error */
static int APP_CC
send_init_response_message(void)
{
    struct stream *s = (struct stream *)NULL;

    LOGM((LOG_LEVEL_INFO, "send_init_response_message:"));
    s = trans_get_out_s(g_con_trans, 8192);

    if (s == 0)
    {
        return 1;
    }

    out_uint32_le(s, 0); /* version */
    out_uint32_le(s, 8 + 8); /* size */
    out_uint32_le(s, 2); /* msg id */
    out_uint32_le(s, 8); /* size */
    s_mark_end(s);
    return trans_write_copy(g_con_trans);
}
コード例 #6
0
ファイル: chansrv.c プロジェクト: nrich/xrdp
/* returns error */
int APP_CC
send_rail_drawing_orders(char* data, int size)
{
    LOGM((LOG_LEVEL_DEBUG, "chansrv::send_rail_drawing_orders: size %d", size));

    struct stream* s;
    int error;

    s = trans_get_out_s(g_con_trans, 8192);
    out_uint32_le(s, 0); /* version */
    out_uint32_le(s, 8 + 8 + size); /* size */
    out_uint32_le(s, 10); /* msg id */
    out_uint32_le(s, 8 + size); /* size */
    out_uint8a(s, data, size);
    s_mark_end(s);
    error = trans_force_write(g_con_trans);
    if (error != 0)
    {
        return 1;
    }
    return 0;
}
コード例 #7
0
ファイル: xrdp_mm.c プロジェクト: LawrenceK/xrdp
static int APP_CC
xrdp_mm_send_login(struct xrdp_mm* self)
{
  struct stream * s = (struct stream *)NULL;
  int rv = 0;
  int index = 0;
  int count = 0;
  char * username = (char *)NULL;
  char * password = (char *)NULL;
  char * name = (char *)NULL;
  char * value = (char *)NULL;

  xrdp_wm_log_msg(self->wm, "sending login info to session manager, "
                            "please wait...");
  username = 0;
  password = 0;
  self->code = 0;
  count = self->login_names->count;
  for (index = 0; index < count; index++)
  {
    name = (char*)list_get_item(self->login_names, index);
    value = (char*)list_get_item(self->login_values, index);
    if (g_strcasecmp(name, "username") == 0)
    {
      username = value;
    }
    else if (g_strcasecmp(name, "password") == 0)
    {
      password = value;
    }
    else if (g_strcasecmp(name, "lib") == 0)
    {
      if ((g_strcasecmp(value, "libxup.so") == 0) ||
          (g_strcasecmp(value, "xup.dll") == 0))
      {
        self->code = 10;
      }
    }
  }
  if ((username == 0) || (password == 0))
  {
    xrdp_wm_log_msg(self->wm, "Error finding username and password");
    return 1;
  }

  s = trans_get_out_s(self->sesman_trans, 8192);
  s_push_layer(s, channel_hdr, 8);
  /* this code is either 0 for Xvnc or 10 for X11rdp */
  out_uint16_be(s, self->code);
  index = g_strlen(username);
  out_uint16_be(s, index);
  out_uint8a(s, username, index);
  index = g_strlen(password);

  out_uint16_be(s, index);
  out_uint8a(s, password, index);
  out_uint16_be(s, self->wm->screen->width);
  out_uint16_be(s, self->wm->screen->height);
  out_uint16_be(s, self->wm->screen->bpp);

  /* send domain */
  index = g_strlen(self->wm->client_info->domain);
  out_uint16_be(s, index);
  out_uint8a(s, self->wm->client_info->domain, index);

  /* send program / shell */
  index = g_strlen(self->wm->client_info->program);
  out_uint16_be(s, index);
  out_uint8a(s, self->wm->client_info->program, index);

  /* send directory */
  index = g_strlen(self->wm->client_info->directory);
  out_uint16_be(s, index);
  out_uint8a(s, self->wm->client_info->directory, index);

  /* send client ip */
  index = g_strlen(self->wm->client_info->client_ip);
  out_uint16_be(s, index);
  out_uint8a(s, self->wm->client_info->client_ip, index);

  s_mark_end(s);

  s_pop_layer(s, channel_hdr);
  out_uint32_be(s, 0); /* version */
  index = (int)(s->end - s->data);
  out_uint32_be(s, index); /* size */

  rv = trans_force_write(self->sesman_trans);

  if (rv != 0) {
    xrdp_wm_log_msg(self->wm, "xrdp_mm_send_login: xrdp_mm_send_login failed");
  }

  return rv;
}
コード例 #8
0
ファイル: sound.c プロジェクト: OSgenie/xrdp
static void *DEFAULT_CC
read_raw_audio_data(void *arg)
{
    pa_sample_spec samp_spec;
    pa_simple *simple = NULL;
    uint32_t bytes_read;
    char *cptr;
    int i;
    int error;
    struct trans *strans;
    char path[256];
    struct stream *outs;

    strans = trans_create(TRANS_MODE_UNIX, 8192, 8192);

    if (strans == 0)
    {
        LOG(0, ("read_raw_audio_data: trans_create failed\n"));
        return 0;
    }

    strans->trans_data_in = sttrans_data_in;
    g_snprintf(path, 255, "/tmp/xrdp_chansrv_audio_socket_%d", g_display_num);

    if (trans_connect(strans, "", path, 100) != 0)
    {
        LOG(0, ("read_raw_audio_data: trans_connect failed\n"));
        trans_delete(strans);
        return 0;
    }

    /* setup audio format */
    samp_spec.format = PA_SAMPLE_S16LE;
    samp_spec.rate = 44100;
    samp_spec.channels = 2;

    /* if we are root, then for first 8 seconds connection to pulseaudo server
       fails; if we are non-root, then connection succeeds on first attempt;
       for now we have changed code to be non-root, but this may change in the
       future - so pretend we are root and try connecting to pulseaudio server
       for upto one minute */
    for (i = 0; i < 60; i++)
    {
        simple = pa_simple_new(NULL, "xrdp", PA_STREAM_RECORD, NULL,
                               "record", &samp_spec, NULL, NULL, &error);

        if (simple)
        {
            /* connected to pulseaudio server */
            LOG(0, ("read_raw_audio_data: connected to pulseaudio server\n"));
            break;
        }

        LOG(0, ("read_raw_audio_data: ERROR creating PulseAudio async interface\n"));
        LOG(0, ("read_raw_audio_data: %s\n", pa_strerror(error)));
        g_sleep(1000);
    }

    if (i == 60)
    {
        /* failed to connect to audio server */
        trans_delete(strans);
        return NULL;
    }

    /* insert header just once */
    outs = trans_get_out_s(strans, 8192);
    out_uint32_le(outs, 0);
    out_uint32_le(outs, AUDIO_BUF_SIZE + 8);
    cptr = outs->p;
    out_uint8s(outs, AUDIO_BUF_SIZE);
    s_mark_end(outs);

    while (1)
    {
        /* read a block of raw audio data... */
        g_memset(cptr, 0, 4);
        bytes_read = pa_simple_read(simple, cptr, AUDIO_BUF_SIZE, &error);

        if (bytes_read < 0)
        {
            LOG(0, ("read_raw_audio_data: ERROR reading from pulseaudio stream\n"));
            LOG(0, ("read_raw_audio_data: %s\n", pa_strerror(error)));
            break;
        }

        /* bug workaround:
           even when there is no audio data, pulseaudio is returning without
           errors but the data itself is zero; we use this zero data to
           determine that there is no audio data present */
        if (*cptr == 0 && *(cptr + 1) == 0 && *(cptr + 2) == 0 && *(cptr + 3) == 0)
        {
            g_sleep(10);
            continue;
        }

        if (trans_force_write_s(strans, outs) != 0)
        {
            LOG(0, ("read_raw_audio_data: ERROR writing audio data to server\n"));
            break;
        }
    }

    pa_simple_free(simple);
    trans_delete(strans);
    return NULL;
}
コード例 #9
0
ファイル: chansrv.c プロジェクト: eric011/xrdp
/* returns error */
static int APP_CC
send_data_from_chan_item(struct chan_item *chan_item)
{
    struct stream *s;
    struct chan_out_data *cod;
    int bytes_left;
    int size;
    int chan_flags;
    int error;

    if (chan_item->head == 0)
    {
        return 0;
    }

    cod = chan_item->head;
    bytes_left = (int)(cod->s->end - cod->s->p);
    size = MIN(1600, bytes_left);
    chan_flags = 0;

    if (cod->s->p == cod->s->data)
    {
        chan_flags |= 1; /* first */
    }

    if (cod->s->p + size >= cod->s->end)
    {
        chan_flags |= 2; /* last */
    }

    s = trans_get_out_s(g_con_trans, 8192);
    out_uint32_le(s, 0); /* version */
    out_uint32_le(s, 8 + 8 + 2 + 2 + 2 + 4 + size); /* size */
    out_uint32_le(s, 8); /* msg id */
    out_uint32_le(s, 8 + 2 + 2 + 2 + 4 + size); /* size */
    out_uint16_le(s, chan_item->id);
    out_uint16_le(s, chan_flags);
    out_uint16_le(s, size);
    out_uint32_le(s, cod->s->size);
    out_uint8a(s, cod->s->p, size);
    s_mark_end(s);
    LOGM((LOG_LEVEL_DEBUG, "chansrv::send_channel_data: -- "
          "size %d chan_flags 0x%8.8x", size, chan_flags));
    error = trans_force_write(g_con_trans);

    if (error != 0)
    {
        return 1;
    }

    cod->s->p += size;

    if (cod->s->p >= cod->s->end)
    {
        free_stream(cod->s);
        chan_item->head = chan_item->head->next;

        if (chan_item->head == 0)
        {
            chan_item->tail = 0;
        }

        g_free(cod);
    }

    return 0;
}