2 utcp.h -- Userspace TCP
3 Copyright (C) 2014 Guus Sliepen <guus@tinc-vpn.org>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32 struct utcp_connection {
38 struct utcp_connection;
41 typedef bool (*utcp_pre_accept_t)(struct utcp *utcp, uint16_t port);
42 typedef void (*utcp_accept_t)(struct utcp_connection *utcp_connection, uint16_t port);
44 typedef int (*utcp_send_t)(struct utcp *utcp, void *data, size_t len);
45 typedef int (*utcp_recv_t)(struct utcp_connection *connection, void *data, size_t len);
47 extern struct utcp *utcp_init(utcp_accept_t accept, utcp_pre_accept_t pre_accept, utcp_send_t send, void *priv);
48 extern void utcp_exit(struct utcp *utcp);
49 extern struct utcp_connection *utcp_connect(struct utcp *utcp, uint16_t port, utcp_recv_t recv, void *priv);
50 extern void utcp_accept(struct utcp_connection *utcp, utcp_recv_t recv, void *priv);
51 extern ssize_t utcp_send(struct utcp_connection *connection, void *data, size_t len);
52 extern int utcp_recv(struct utcp *utcp, void *data, size_t len);
53 extern int utcp_close(struct utcp_connection *connection);
54 extern int utcp_abort(struct utcp_connection *connection);
55 extern int utcp_shutdown(struct utcp_connection *connection, int how);
56 extern void utcp_timeout(struct utcp *utcp);