|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
Outbound TCP / UDP client sockets for plugin network protocols. More...
#include "plugin_manager/SlotTable.h"#include "plugin_manager/host_api.h"#include "plugin_manager/Plugin.h"#include "cdc_log.h"#include "lwip/sockets.h"#include "lwip/netdb.h"#include <cerrno>#include <cstdio>#include <fcntl.h>#include <unistd.h>Go to the source code of this file.
Functions | |
| void * | plg_get_active_plugin (void) |
| int | host_socket_open (uint8_t proto, const char *host, uint16_t port, uint32_t timeout_ms) |
| Open an outbound connection to a single remote endpoint. | |
| int | host_socket_write (int handle, const uint8_t *data, size_t len, uint32_t timeout_ms) |
| Write bytes to the stream / send a datagram to the connected peer. | |
| int | host_socket_read (int handle, uint8_t *out, size_t cap, uint32_t timeout_ms) |
| Read bytes from the stream / receive a datagram from the connected peer. | |
| int | host_socket_close (int handle) |
| Close a socket handle. | |
| void | plg_socket_on_unload (void *plugin) |
Outbound TCP / UDP client sockets for plugin network protocols.
Plugins open a handle with host_socket_open (HOST_SOCK_TCP / HOST_SOCK_UDP), exchange bytes via host_socket_write / host_socket_read, and release it with host_socket_close. Up to MAX_SOCKET_SLOTS handles are tracked in a fixed slot table keyed by 1-based integer handle; handles leaked by a crashing or exiting plugin are swept in plg_socket_on_unload. Both protocols are connected: a UDP socket fixes its peer at open time via connect(), so the read/write path is identical for both. Gated on the "socket" capability. lwIP owns DNS resolution and the protocol stacks; per-call timeouts map to SO_RCVTIMEO / SO_SNDTIMEO, the TCP connect timeout to a non-blocking connect bounded by select().
Definition in file host_api_socket.cpp.
| void * plg_get_active_plugin | ( | void | ) |
Definition at line 24 of file plugin_log_bridge.cpp.
Referenced by host_socket_open().
| void plg_socket_on_unload | ( | void * | plugin | ) |
Definition at line 204 of file host_api_socket.cpp.
References LOG_W, cdc::plugin_manager::SlotTable< T, N >::slots, and TAG.