File: ercp_process.c

package info (click to toggle)
xrdp 0.10.5-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 15,104 kB
  • sloc: ansic: 107,426; sh: 5,852; asm: 4,742; cpp: 2,555; makefile: 1,474
file content (102 lines) | stat: -rw-r--r-- 2,929 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/**
 * xrdp: A Remote Desktop Protocol server.
 *
 * Copyright (C) Jay Sorg 2004-2023
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 *
 * @file ercp_process.c
 * @brief ERCP (executive run-time control protocol) handler function
 * @author Matt Burt
 *
 */

#if defined(HAVE_CONFIG_H)
#include <config_ac.h>
#endif

#include <stdio.h>

#include "trans.h"

#include "ercp.h"
#include "ercp_process.h"
#include "session_list.h"

/******************************************************************************/
static int
process_session_announce_event(struct session_item *si)
{
    int rv;
    const char *start_ip_addr;

    rv = ercp_get_session_announce_event(si->sesexec_trans,
                                         NULL,
                                         &si->uid,
                                         &si->type,
                                         &si->start_width,
                                         &si->start_height,
                                         &si->bpp,
                                         &si->guid,
                                         &start_ip_addr,
                                         &si->start_time);
    if (rv == 0)
    {
        snprintf(si->start_ip_addr, sizeof(si->start_ip_addr),
                 "%s", start_ip_addr);
        si->state = E_SESSION_RUNNING;
    }

    return rv;
}

/******************************************************************************/
static void
process_session_finished_event(struct session_item *si)
{
    LOG(LOG_LEVEL_INFO, "Session on display %d has finished.",
        si->display);
    // Setting the transport down will remove this connection from the list
    si->sesexec_trans->status = TRANS_STATUS_DOWN;
}

/******************************************************************************/
int
ercp_process(struct session_item *si)
{
    enum ercp_msg_code msgno;
    int rv = 0;

    switch ((msgno = ercp_msg_in_get_msgno(si->sesexec_trans)))
    {
        case E_ERCP_SESSION_ANNOUNCE_EVENT:
            rv = process_session_announce_event(si);
            break;

        case E_ERCP_SESSION_FINISHED_EVENT:
            process_session_finished_event(si);
            break;

        default:
        {
            char buff[64];
            ercp_msgno_to_str(msgno, buff, sizeof(buff));
            LOG(LOG_LEVEL_ERROR, "Ignored EICP message %s", buff);
        }
    }
    return rv;
}