cscg24-guacamole

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

ttymode.h (2793B)


      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_SSH_TTYMODE_H
     21#define GUAC_SSH_TTYMODE_H
     22
     23#include "config.h"
     24
     25#include <stdint.h>
     26
     27/**
     28 * The size of a TTY mode encoding opcode and
     29 * value pair.  As defined in the SSH RFC, this
     30 * is 5 bytes - a single byte for the opcode, and
     31 * 4 bytes for the value.
     32 */
     33#define GUAC_SSH_TTY_OPCODE_SIZE 5
     34
     35/**
     36 * The SSH TTY mode encoding opcode that terminates
     37 * the list of TTY modes.
     38 */
     39#define GUAC_SSH_TTY_OP_END 0
     40
     41/**
     42 * The SSH TTY mode encoding opcode that configures
     43 * the TTY erase code to configure the server
     44 * backspace key.
     45 */
     46#define GUAC_SSH_TTY_OP_VERASE 3
     47
     48/**
     49 * Macro for calculating the number of bytes required
     50 * to pass a given number of opcodes, which calculates
     51 * the size of the number of opcodes plus the single byte
     52 * end opcode.
     53 *
     54 * @param num_opcodes
     55 *     The number of opcodes for which a size in bytes
     56 *     should be calculated.
     57 *
     58 * @returns
     59 *     The number of bytes that the given number of
     60 *     opcodes will require.
     61 */
     62#define GUAC_SSH_TTYMODES_SIZE(num_opcodes) ((GUAC_SSH_TTY_OPCODE_SIZE * num_opcodes) + 1)
     63
     64/**
     65 * Opcodes and value pairs are passed to the SSH connection
     66 * in a single array, beginning with the opcode and followed
     67 * by a four byte value, repeating until the end opcode is
     68 * encountered.  This function takes the array that will be
     69 * sent and a variable number of opcode and value pair
     70 * arguments and places the opcode and values in the array
     71 * as expected by the SSH connection.
     72 *
     73 * @param opcode_array
     74 *     Pointer to the opcode array that will ultimately
     75 *     be passed to the SSH connection.  The array must
     76 *     be size to handle 5 bytes for each opcode and value
     77 *     pair, plus one additional byte for the end opcode.
     78 *
     79 * @params ...
     80 *     A variable number of opcode and value pairs
     81 *     to place in the array.
     82 *
     83 * @return
     84 *     Number of bytes written to the array, or zero
     85 *     if a failure occurs.
     86 */
     87int guac_ssh_ttymodes_init(char opcode_array[], ...);
     88
     89#endif