|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
Accept inbound TCP connections on a plugin-chosen port. More...
Functions | |
| int | host_net_listen (uint16_t port, uint32_t action_id) |
| Start a TCP listener on port; fires action_id while clients wait. | |
| int | host_net_accept (void) |
| Take the next accepted connection as a socket handle for host_socket_read/write/close. | |
| int | host_net_close (uint16_t port) |
| Stop the listener (pass 0 or the listening port). Closes pending un-accepted connections. | |
Accept inbound TCP connections on a plugin-chosen port.
The client socket API is outbound-only; this adds the server side. The plugin picks the port; the firmware binds/listens/accepts on a dedicated task and fires action_id while connections wait. The handler calls host_net_accept to take the next connection as a socket handle, then drives it with the normal host_socket_read / host_socket_write / host_socket_close (no extra Socket (TCP / UDP client) capability needed for an accepted connection). Requires manifest capability "net_listen". WiFi must be up (host_wifi_request) for clients to reach the badge; the listener itself binds regardless and simply waits. One listener per plugin. The listen socket is transparently re-opened after a network drop across light sleep.
| int host_net_accept | ( | void | ) |
Take the next accepted connection as a socket handle for host_socket_read/write/close.
Definition at line 115 of file host_api_net.cpp.
References HOST_ERR_NO_CAPABILITY, HOST_ERR_NOT_FOUND, plg_get_active_plugin(), and plg_socket_adopt().
Referenced by cdc::plugin_manager::w_host_net_accept().
| int host_net_close | ( | uint16_t | port | ) |
Stop the listener (pass 0 or the listening port). Closes pending un-accepted connections.
Definition at line 127 of file host_api_net.cpp.
References HOST_ERR_NO_CAPABILITY, HOST_ERR_NOT_FOUND, HOST_OK, and plg_get_active_plugin().
Referenced by cdc::plugin_manager::w_host_net_close().
| int host_net_listen | ( | uint16_t | port, |
| uint32_t | action_id ) |
Start a TCP listener on port; fires action_id while clients wait.
Definition at line 89 of file host_api_net.cpp.
References HOST_ERR_BUSY, HOST_ERR_INVALID_ARG, HOST_ERR_NO_CAPABILITY, HOST_OK, LOG_I, LOG_W, plg_get_active_plugin(), and TAG.
Referenced by cdc::plugin_manager::w_host_net_listen().