static inline void telnet_reply_command(void) { if (k_sem_take(&cmd_lock, K_NO_WAIT)) { return; } if (!telnet_cmd.iac) { goto out; } switch (telnet_cmd.op) { case NVT_CMD_AO: /* OK, no output then */ __printk_hook_install(telnet_console_out_nothing); telnet_rb_init(); break; case NVT_CMD_AYT: telnet_reply_ay_command(); break; case NVT_CMD_DO: telnet_reply_do_command(); break; default: SYS_LOG_DBG("Operation %u not handled", telnet_cmd.op); break; } telnet_cmd.iac = NVT_NUL; telnet_cmd.op = NVT_NUL; telnet_cmd.opt = NVT_NUL; out: k_sem_give(&cmd_lock); }
static void telnet_accept(struct net_context *client, struct sockaddr *addr, socklen_t addrlen, int error, void *user_data) { if (error) { LOG_ERR("Error %d", error); goto error; } if (client_cnx) { LOG_WRN("A telnet client is already in."); goto error; } if (net_context_recv(client, telnet_recv, 0, NULL)) { LOG_ERR("Unable to setup reception (family %u)", net_context_get_family(client)); goto error; } LOG_DBG("Telnet client connected (family AF_INET%s)", net_context_get_family(client) == AF_INET ? "" : "6"); orig_printk_hook = __printk_get_hook(); __printk_hook_install(telnet_console_out); client_cnx = client; k_timer_start(&send_timer, TELNET_TIMEOUT, TELNET_TIMEOUT); return; error: net_context_put(client); }
static void telnet_end_client_connection(void) { __printk_hook_install(orig_printk_hook); orig_printk_hook = NULL; k_timer_stop(&send_timer); net_context_put(client_cnx); client_cnx = NULL; telnet_rb_init(); }
static int bt_monitor_init(struct device *d) { ARG_UNUSED(d); monitor_dev = device_get_binding(CONFIG_BLUETOOTH_MONITOR_ON_DEV_NAME); #if defined(CONFIG_UART_INTERRUPT_DRIVEN) uart_irq_rx_disable(monitor_dev); uart_irq_tx_disable(monitor_dev); #endif #if !defined(CONFIG_UART_CONSOLE) __printk_hook_install(monitor_console_out); __stdout_hook_install(monitor_console_out); #endif return 0; }
int ipm_console_sender_init(struct device *d) { const struct ipm_console_sender_config_info *config_info; config_info = d->config->config_info; ipm_console_device = device_get_binding(config_info->bind_to); if (!ipm_console_device) { printk("unable to bind IPM console sender to '%s'\n", config_info->bind_to); return -EINVAL; } if (config_info->flags & IPM_CONSOLE_STDOUT) { __stdout_hook_install(consoleOut); } if (config_info->flags & IPM_CONSOLE_PRINTK) { __printk_hook_install(consoleOut); } return 0; }
void uart_console_hook_install(void) { __stdout_hook_install(console_out); __printk_hook_install(console_out); }
static void consoleInit(void) { __printk_hook_install(_mbxPollOut); __stdout_hook_install(_mbxPollOut); }