blob: 20fee9b370ad77e209c769725672965644b4e274 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
/* SPDX-License-Identifier: GPL-3.0-or-later */
#pragma once
#include <netinet/in.h>
#include <stdint.h>
//
// 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);
|