25#ifndef PROTOCORE_UDP_H
26#define PROTOCORE_UDP_H
117bool pc_udp_sendto(
const char *dst_ip, uint16_t dst_port,
const uint8_t *data,
size_t len);
137bool pc_udp_listener_sendto(uint16_t listen_port,
const char *dst_ip, uint16_t dst_port,
const uint8_t *data,
145void pc_udp_capture_enable();
146void pc_udp_capture_reset();
147const uint8_t *pc_udp_captured();
148size_t pc_udp_captured_len();
152void pc_udp_inject(uint16_t listen_port,
const char *src_ip, uint16_t src_port,
const uint8_t *data,
size_t len);
153void pc_udp_set_listener_sendto_result(
bool ok);
154void pc_udp_reset_listeners();
157const char *pc_udp_joined_group(uint16_t
port);
User-facing configuration for ProtoCore.
bool pc_udp_sendto(const char *dst_ip, uint16_t dst_port, const uint8_t *data, size_t len)
Send a UDP datagram to an arbitrary destination (outbound client).
void(* pc_udp_handler)(const uint8_t *data, size_t len, const struct pc_udp_peer *peer, void *ctx)
Datagram handler invoked for each received UDP packet.
bool pc_udp_listener_sendto(uint16_t listen_port, const char *dst_ip, uint16_t dst_port, const uint8_t *data, size_t len)
Send a datagram from the listener bound on listen_port to an address.
bool pc_udp_listen(uint16_t port, pc_udp_handler handler, void *ctx)
Bind a UDP port and route incoming datagrams to handler.
bool pc_udp_send(const struct pc_udp_peer *peer, const uint8_t *data, size_t len)
Send a datagram back to the peer captured during the handler call.
bool pc_udp_listen_multicast(const char *group_ip, uint16_t port, pc_udp_handler handler, void *ctx)
Bind a UDP port, join an IPv4 multicast group, and route group datagrams to handler.
bool pc_udp_leave_multicast(uint16_t port)
Leave the multicast group joined on port and release its listener slot.
bool pc_udp_peer_addr(const struct pc_udp_peer *peer, char *ip_out, size_t ip_cap, uint16_t *port_out)
Copy a received peer's source IPv4 address (dotted-quad) and port out.