Files
ttynvt/telnet_rfc2217.c
T
Kim Woelders effca015a8 Fix running on big endian
RFC2217 options with one byte values were always sent with value = 0.
2018-10-25 07:27:21 +02:00

55 lines
1.2 KiB
C

/*
* Copyright (c) 2018 Lars Thrane A/S
* SPDX-License-Identifier: GPL-2.0
*
* Telnet server - RFC-2217 handling
*/
#include <stddef.h>
#include "telnet.h"
#include "telnet_param.h"
void telnet_rfc2217_handle_opt(tn_ctx_t * tcc, int opt,
unsigned char *pu, int nd)
{
unsigned int sub;
sub = pu[0];
switch (sub)
{
default:
break;
case 100: /* SIGNATURE */
telnet_set_opt(tcc, opt, 0, "LT-NVT", 6);
break;
case 106: /* NOTIFY-LINESTATE */
break;
case 107: /* NOTIFY-MODEMSTATE */
if (tcc->srv_ms)
tcc->srv_ms(tcc->cctx, pu[1]);
break;
case 108: /* FLOWCONTROL-SUSPEND */
case 109: /* FLOWCONTROL-RESUME */
break;
}
}
void telnet_rfc2217_cfg(tn_ctx_t * tcc, int cmd, const void *val, int nd)
{
if (!tcc->mode_rfc2217)
return;
telnet_set_opt(tcc, TNO_CPCO, cmd, val, nd);
}
void telnet_rfc2217_ctl(tn_ctx_t * tcc, unsigned int val)
{
unsigned char byte = val;
if (!tcc->mode_rfc2217)
return;
telnet_set_opt(tcc, TNO_CPCO, TNS_SET_CONTROL, &byte, 1);
}