static void setup_tcp_accept(struct net_context *tcp_recv6) { int ret; ret = net_context_accept(tcp_recv6, tcp_accepted, 0, NULL); if (ret < 0) { printk("Cannot receive IPv6 TCP packets (%d)", ret); } }
static void setup_tcp_accept(struct net_context *tcp_recv4, struct net_context *tcp_recv6) { int ret; #if defined(CONFIG_NET_IPV6) ret = net_context_accept(tcp_recv6, tcp_accepted, 0, NULL); if (ret < 0) { NET_ERR("Cannot receive IPv6 TCP packets (%d)", ret); } #endif /* CONFIG_NET_IPV6 */ #if defined(CONFIG_NET_IPV4) ret = net_context_accept(tcp_recv4, tcp_accepted, 0, NULL); if (ret < 0) { NET_ERR("Cannot receive IPv4 TCP packets (%d)", ret); } #endif /* CONFIG_NET_IPV4 */ }
static void telnet_setup_server(struct net_context **ctx, sa_family_t family, struct sockaddr *addr, socklen_t addrlen) { if (net_context_get(family, SOCK_STREAM, IPPROTO_TCP, ctx)) { SYS_LOG_ERR("No context available"); goto error; } if (net_context_bind(*ctx, addr, addrlen)) { SYS_LOG_ERR("Cannot bind on family AF_INET%s", family == AF_INET ? "" : "6"); goto error; } if (net_context_listen(*ctx, 0)) { SYS_LOG_ERR("Cannot listen on"); goto error; } if (net_context_accept(*ctx, telnet_accept, 0, NULL)) { SYS_LOG_ERR("Cannot accept"); goto error; } SYS_LOG_DBG("Telnet console enabled on AF_INET%s", family == AF_INET ? "" : "6"); return; error: SYS_LOG_ERR("Unable to start telnet on AF_INET%s", family == AF_INET ? "" : "6"); if (*ctx) { net_context_put(*ctx); *ctx = NULL; } }