cscg24-guacamole

CSCG 2024 Challenge 'Guacamole Mashup'
git clone https://git.sinitax.com/sinitax/cscg24-guacamole
Log | Files | Refs | sfeed.txt

pipe-svc.h (6670B)


      1/*
      2 * Licensed to the Apache Software Foundation (ASF) under one
      3 * or more contributor license agreements.  See the NOTICE file
      4 * distributed with this work for additional information
      5 * regarding copyright ownership.  The ASF licenses this file
      6 * to you under the Apache License, Version 2.0 (the
      7 * "License"); you may not use this file except in compliance
      8 * with the License.  You may obtain a copy of the License at
      9 *
     10 *   http://www.apache.org/licenses/LICENSE-2.0
     11 *
     12 * Unless required by applicable law or agreed to in writing,
     13 * software distributed under the License is distributed on an
     14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     15 * KIND, either express or implied.  See the License for the
     16 * specific language governing permissions and limitations
     17 * under the License.
     18 */
     19
     20#ifndef GUAC_RDP_CHANNELS_PIPE_SVC_H
     21#define GUAC_RDP_CHANNELS_PIPE_SVC_H
     22
     23#include "channels/common-svc.h"
     24
     25#include <freerdp/freerdp.h>
     26#include <freerdp/svc.h>
     27#include <guacamole/client.h>
     28#include <guacamole/stream.h>
     29#include <guacamole/socket.h>
     30#include <guacamole/user.h>
     31#include <winpr/wtsapi.h>
     32
     33/**
     34 * The maximum number of bytes to allow within each channel name, including
     35 * null terminator.
     36 */
     37#define GUAC_RDP_SVC_MAX_LENGTH 8
     38
     39/**
     40 * Structure describing a static virtual channel and a corresponding Guacamole
     41 * pipe stream;
     42 */
     43typedef struct guac_rdp_pipe_svc {
     44
     45    /**
     46     * The output pipe, opened when the RDP server receives a connection to
     47     * the static channel.
     48     */
     49    guac_stream* output_pipe;
     50
     51    /**
     52     * The underlying static channel. Data written to this SVC by the RDP
     53     * server will be forwarded along the pipe stream to the Guacamole client,
     54     * and data written to the pipe stream by the Guacamole client will be
     55     * forwarded along the SVC to the RDP server.
     56     */
     57    guac_rdp_common_svc* svc;
     58
     59} guac_rdp_pipe_svc;
     60
     61/**
     62 * Initializes arbitrary static virtual channel (SVC) support for RDP, handling
     63 * communication for the SVC having the given name. Data sent from within the
     64 * RDP session using this channel will be sent along an identically-named pipe
     65 * stream to the Guacamole client, and data sent along a pipe stream having the
     66 * same name will be written to the SVC and received within the RDP session. If
     67 * failures occur while loading the plugin, messages noting the specifics of
     68 * those failures will be logged, and support for the given channel will not be
     69 * functional.
     70 *
     71 * This MUST be called within the PreConnect callback of the freerdp instance
     72 * for static virtual channel support to be loaded.
     73 *
     74 * @param context
     75 *     The rdpContext associated with the FreeRDP side of the RDP connection.
     76 *
     77 * @param name
     78 *     The name of the SVC which should be handled.
     79 */
     80void guac_rdp_pipe_svc_load_plugin(rdpContext* context, char* name);
     81
     82/**
     83 * Sends the "pipe" instruction describing the given static virtual channel
     84 * along the given socket. This pipe instruction will relate the SVC's
     85 * underlying output stream with the SVC's name and the mimetype
     86 * "application/octet-stream".
     87 *
     88 * @param socket
     89 *     The socket along which the "pipe" instruction should be sent.
     90 *
     91 * @param svc
     92 *     The static virtual channel that the "pipe" instruction should describe.
     93 */
     94void guac_rdp_pipe_svc_send_pipe(guac_socket* socket, guac_rdp_pipe_svc* svc);
     95
     96/**
     97 * Sends the "pipe" instructions describing all static virtual channels
     98 * available to the all users associated with the provided socket. Each pipe
     99 * instruction will relate the associated SVC's underlying output stream with
    100 * the SVC's name and the mimetype "application/octet-stream".
    101 *
    102 * @param client
    103 *     The client associated with the users being sent the pipe instruction.
    104 *
    105 * @param socket
    106 *     The socket to send the pipe instruction accross.
    107 */
    108void guac_rdp_pipe_svc_send_pipes(
    109        guac_client* client, guac_socket* socket);
    110
    111/**
    112 * Add the given SVC to the list of all available SVCs. This function must be
    113 * invoked after the SVC is connected for inbound pipe streams having that
    114 * SVC's name to result in received data being sent into the RDP session.
    115 *
    116 * @param client
    117 *     The guac_client associated with the current RDP session.
    118 *
    119 * @param svc
    120 *     The static virtual channel to add to the list of all such channels
    121 *     available.
    122 */
    123void guac_rdp_pipe_svc_add(guac_client* client, guac_rdp_pipe_svc* svc);
    124
    125/**
    126 * Retrieve the SVC with the given name from the list stored in the client. The
    127 * requested SVC must previously have been added using guac_rdp_pipe_svc_add().
    128 *
    129 * @param client
    130 *     The guac_client associated with the current RDP session.
    131 *
    132 * @param name
    133 *     The name of the static virtual channel to retrieve.
    134 *
    135 * @return
    136 *     The static virtual channel with the given name, or NULL if no such
    137 *     virtual channel exists.
    138 */
    139guac_rdp_pipe_svc* guac_rdp_pipe_svc_get(guac_client* client, const char* name);
    140
    141/**
    142 * Removes the SVC with the given name from the list stored in the client.
    143 * Inbound pipe streams having the given name will no longer be routed to the
    144 * associated SVC.
    145 *
    146 * @param client
    147 *     The guac_client associated with the current RDP session.
    148 *
    149 * @param name
    150 *     The name of the static virtual channel to remove.
    151 *
    152 * @return
    153 *     The static virtual channel that was removed, or NULL if no such virtual
    154 *     channel exists.
    155 */
    156guac_rdp_pipe_svc* guac_rdp_pipe_svc_remove(guac_client* client, const char* name);
    157
    158/**
    159 * Handler for "blob" instructions which writes received data to the associated
    160 * SVC using guac_rdp_pipe_svc_write().
    161 */
    162guac_user_blob_handler guac_rdp_pipe_svc_blob_handler;
    163
    164/**
    165 * Handler for "pipe" instructions which prepares received pipe streams to
    166 * write received blobs to the SVC having the same name as the pipe stream.
    167 * Received pipe streams are associated with the relevant guac_rdp_pipe_svc
    168 * instance and the SVC-specific "blob" instruction handler
    169 * (guac_rdp_pipe_svc_blob_handler).
    170 */
    171guac_user_pipe_handler guac_rdp_pipe_svc_pipe_handler;
    172
    173/**
    174 * Handler which is invoked when an SVC associated with a Guacamole pipe stream
    175 * is connected to the RDP server.
    176 */
    177guac_rdp_common_svc_connect_handler guac_rdp_pipe_svc_process_connect;
    178
    179/**
    180 * Handler which is invoked when an SVC associated with a Guacamole pipe stream
    181 * received data from the RDP server.
    182 */
    183guac_rdp_common_svc_receive_handler guac_rdp_pipe_svc_process_receive;
    184
    185/**
    186 * Handler which is invoked when an SVC associated with a Guacamole pipe stream
    187 * has disconnected and is about to be freed.
    188 */
    189guac_rdp_common_svc_terminate_handler guac_rdp_pipe_svc_process_terminate;
    190
    191#endif
    192