summaryrefslogtreecommitdiff
path: root/libhw_cr/host_include/libhw/host_net.h
blob: fced22920614a4d9324b36a87e060e15f74bcbe6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* libhw/host_net.h - <libhw/generic/net.h> implementation for hosted glibc
 *
 * Copyright (C) 2024-2025  Luke T. Shumaker <lukeshu@lukeshu.com>
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

#ifndef _LIBHW_HOST_NET_H_
#define _LIBHW_HOST_NET_H_

#include <stdint.h> /* for uint16_6 */

#include <libmisc/private.h>

#include <libhw/generic/net.h>

struct _hostnet_tcp_conn {
	BEGIN_PRIVATE(LIBHW_HOST_NET_H)
	int                              fd;
	uint64_t                         read_deadline_ns;
	END_PRIVATE(LIBHW_HOST_NET_H)
};
LO_IMPLEMENTATION_H(net_stream_conn, struct _hostnet_tcp_conn, hostnet_tcp)

struct hostnet_tcp_listener {
	BEGIN_PRIVATE(LIBHW_HOST_NET_H)
	int                              fd;
	struct _hostnet_tcp_conn         active_conn;
	END_PRIVATE(LIBHW_HOST_NET_H)
};
LO_IMPLEMENTATION_H(net_stream_listener, struct hostnet_tcp_listener, hostnet_tcplist)

void hostnet_tcp_listener_init(struct hostnet_tcp_listener *self, uint16_t port);

struct hostnet_udp_conn {
	BEGIN_PRIVATE(LIBHW_HOST_NET_H)
	int                              fd;
	uint64_t                         read_deadline_ns;
	END_PRIVATE(LIBHW_HOST_NET_H)
};
LO_IMPLEMENTATION_H(net_packet_conn, struct hostnet_udp_conn, hostnet_udp)

void hostnet_udp_conn_init(struct hostnet_udp_conn *self, uint16_t port);

#endif /* _LIBHW_HOST_NET_H_ */