Example #1
0
static void
handle_state_subneg(TelnetProtocol *self,
                    ZPktBuf *data)
{
    guint8 byte;

    g_assert(z_pktbuf_get_u8(data, &byte));

    if (byte == TELNET_IAC)
        change_state(self, PROTO_STATE_SUBNEG_ESCAPED);
    else
        append_byte(self, self->subneg_buffer, byte);
}
Example #2
0
static void
handle_state_subneg_escaped(TelnetProtocol *self,
                            ZPktBuf *data)
{
    guint8 byte;

    g_assert(z_pktbuf_get_u8(data, &byte));

    if (byte == TELNET_CMD_SE)
    {
        change_state(self, PROTO_STATE_DATA);
        call_data_received(self);
        call_subneg_received(self);
    }
    else
    {
        change_state(self, PROTO_STATE_SUBNEG);
        append_byte(self, self->subneg_buffer, byte);
    }
}
Example #3
0
static void
handle_state_escaped(TelnetProtocol *self,
                     ZPktBuf *data)
{
    guint8 byte;

    g_assert(z_pktbuf_get_u8(data, &byte));

    self->command = byte;

    switch (byte)
    {
    case TELNET_IAC:
        change_state(self, PROTO_STATE_DATA);
        append_byte(self, self->data_buffer, byte);
        call_data_received(self);
        break;

    case TELNET_CMD_SB:
        change_state(self, PROTO_STATE_SUBNEG);
        z_pktbuf_resize(self->subneg_buffer, 0);
        break;

    case TELNET_CMD_WILL:
    case TELNET_CMD_WONT:
    case TELNET_CMD_DO:
    case TELNET_CMD_DONT:
        change_state(self, PROTO_STATE_OPNEG);
        break;

    default:
        change_state(self, PROTO_STATE_DATA);
        call_data_received(self);
        call_command_received(self);
        break;
    }
}
Example #4
0
void append_defs(int num_bytes, Byte fill)
{
	while (num_bytes-- > 0)
		append_byte(fill);
}