Changeset 2a180307 in mainline


Ignore:
Timestamp:
2012-01-12T09:45:21Z (12 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c17c4e28
Parents:
99c2e9f3
Message:

remcons: ignore telnet commands

Location:
uspace/srv/hid/remcons
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/remcons/telnet.h

    r99c2e9f3 r2a180307  
    4545
    4646#define TELNET_IAC 255
     47
    4748#define TELNET_WILL 251
    4849#define TELNET_WONT 252
     50#define TELNET_DO 253
     51#define TELNET_DONT 254
     52
     53#define TELNET_IS_OPTION_CODE(code) (((code) >= 251) && ((code) <= 254))
     54
    4955#define TELNET_ECHO 1
    5056#define TELNET_SUPPRESS_GO_AHEAD 3
  • uspace/srv/hid/remcons/user.c

    r99c2e9f3 r2a180307  
    5555#include <assert.h>
    5656#include "user.h"
     57#include "telnet.h"
    5758
    5859static FIBRIL_MUTEX_INITIALIZE(users_guard);
     
    228229}
    229230
     231static void process_telnet_command(telnet_user_t *user,
     232    telnet_cmd_t option_code, telnet_cmd_t cmd)
     233{
     234        if (option_code != 0) {
     235                telnet_user_log(user, "Ignoring telnet command %u %u %u.",
     236                    TELNET_IAC, option_code, cmd);
     237        } else {
     238                telnet_user_log(user, "Ignoring telnet command %u %u.",
     239                    TELNET_IAC, cmd);
     240        }
     241}
     242
    230243int telnet_user_get_next_keyboard_event(telnet_user_t *user, kbd_event_t *event)
    231244{
     
    233246        if (list_empty(&user->in_events.list)) {
    234247                char next_byte = 0;
     248                bool inside_telnet_command = false;
     249
     250                telnet_cmd_t telnet_option_code = 0;
     251
    235252                /* Skip zeros, bail-out on error. */
    236253                while (next_byte == 0) {
    237254                        int rc = telnet_user_recv_next_byte_no_lock(user, &next_byte);
    238                         DEBUG("Got %d.\n", next_byte);
    239255                        if (rc != EOK) {
    240256                                fibril_mutex_unlock(&user->guard);
    241257                                return rc;
     258                        }
     259                        uint8_t byte = (uint8_t) next_byte;
     260
     261                        /* Skip telnet commands. */
     262                        if (inside_telnet_command) {
     263                                inside_telnet_command = false;
     264                                next_byte = 0;
     265                                if (TELNET_IS_OPTION_CODE(byte)) {
     266                                        telnet_option_code = byte;
     267                                        inside_telnet_command = true;
     268                                } else {
     269                                        process_telnet_command(user,
     270                                            telnet_option_code, byte);
     271                                }
     272                        }
     273                        if (byte == TELNET_IAC) {
     274                                inside_telnet_command = true;
     275                                next_byte = 0;
    242276                        }
    243277                }
Note: See TracChangeset for help on using the changeset viewer.