static inline void telnet_handle_input(struct net_pkt *pkt) { struct console_input *input; size_t len; len = net_pkt_remaining_data(pkt); if (len > CONSOLE_MAX_LINE_LEN || len < TELNET_MIN_MSG) { return; } if (telnet_handle_command(pkt)) { return; } if (!avail_queue || !input_queue) { return; } input = k_fifo_get(avail_queue, K_NO_WAIT); if (!input) { return; } len = MIN(len, CONSOLE_MAX_LINE_LEN); if (net_pkt_read_new(pkt, (u8_t *)input->line, len)) { return; } /* LF/CR will be removed if only the line is not NUL terminated */ if (input->line[len - 1] != NVT_NUL) { if (input->line[len - 1] == NVT_LF) { input->line[len - 1] = NVT_NUL; } if (input->line[len - 2] == NVT_CR) { input->line[len - 2] = NVT_NUL; } } k_fifo_put(input_queue, input); }
static inline void telnet_handle_input(struct net_pkt *pkt) { struct console_input *input; u16_t len, offset, pos; len = net_pkt_appdatalen(pkt); if (len > CONSOLE_MAX_LINE_LEN || len < TELNET_MIN_MSG) { return; } if (telnet_handle_command(pkt)) { return; } if (!avail_queue || !input_queue) { return; } input = k_fifo_get(avail_queue, K_NO_WAIT); if (!input) { return; } offset = net_pkt_get_len(pkt) - len; net_frag_read(pkt->frags, offset, &pos, len, input->line); /* LF/CR will be removed if only the line is not NUL terminated */ if (input->line[len-1] != NVT_NUL) { if (input->line[len-1] == NVT_LF) { input->line[len-1] = NVT_NUL; } if (input->line[len-2] == NVT_CR) { input->line[len-2] = NVT_NUL; } } k_fifo_put(input_queue, input); }