Source
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
ZBX_VECTOR_IMPL(telnet_recv, unsigned char)
static const char *get_telnet_step_string(zbx_zabbix_telnet_step_t step)
{
switch (step)
{
case ZABBIX_TELNET_STEP_CONNECT_INIT:
return "init";
case ZABBIX_TELNET_STEP_CONNECT_WAIT:
return "connect";
case ZABBIX_TELNET_STEP_SEND:
return "send";
case ZABBIX_TELNET_STEP_RECV:
return "receive";
default:
return "unknown";
}
}
static char telnet_lastchar(const char *buf, int offset)
{
while (0 < offset)
{
offset--;
if (' ' != buf[offset])
return buf[offset];
}
return '\0';
}
static zbx_telnet_protocol_step_t async_telnet_recv(zbx_telnet_context_t *telnet_context, short *events)
{
ssize_t nbytes;
zbx_socket_t *s = &telnet_context->s;
zbx_recv_context_t *r = &telnet_context->recv_context;