/* SPDX-License-Identifier: GPL-3.0-or-later */ #pragma once #include #include // // This module implements a peer-to-peer(ish) UDP connection where one side binds // a port and waits for the other side to connect from a specific IP address. // // Both sockets have IP_PMTUDISC_DO set, meaning packets larger than the // path MTU will be dropped or fail with EMSGSIZE. // /// Bind to a UDP port and wait for handshake from the specified ip. /// Returns sockfd on success, -1 on failure (errno is set). int p2p_bind(uint16_t port, in_addr_t ip); /// Connect to a peer-to-peer UDP socket. Timeout is in milliseconds. /// Returns sockfd on success, -1 on failure (errno is set). int p2p_connect(uint16_t port, in_addr_t ip, int timeout);