summaryrefslogtreecommitdiff
path: root/libhw_cr/host_include/libhw/host_net.h
diff options
context:
space:
mode:
Diffstat (limited to 'libhw_cr/host_include/libhw/host_net.h')
-rw-r--r--libhw_cr/host_include/libhw/host_net.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/libhw_cr/host_include/libhw/host_net.h b/libhw_cr/host_include/libhw/host_net.h
new file mode 100644
index 0000000..fced229
--- /dev/null
+++ b/libhw_cr/host_include/libhw/host_net.h
@@ -0,0 +1,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_ */