summaryrefslogtreecommitdiff
path: root/libhw/common_include
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-11-10 22:08:02 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-11-10 22:08:02 -0700
commitd84daf84d2ced072782ef3c61e5088b06d950939 (patch)
treefff4e2f44f01113dff27328e9e74caf4a12f962a /libhw/common_include
parent1e8897a61addec5c2067ffbab38122d6c236ced3 (diff)
libhw: net.h: Add listener close(), add 'iface'
Diffstat (limited to 'libhw/common_include')
-rw-r--r--libhw/common_include/libhw/generic/net.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/libhw/common_include/libhw/generic/net.h b/libhw/common_include/libhw/generic/net.h
index e23dcda..def533c 100644
--- a/libhw/common_include/libhw/generic/net.h
+++ b/libhw/common_include/libhw/generic/net.h
@@ -52,6 +52,14 @@ struct net_stream_listener_vtable {
* connection is still open.
*/
implements_net_stream_conn *(*accept)(implements_net_stream_listener *self);
+
+ /**
+ * The net_stream_conn returned from accept() may still be
+ * valid after the listener is closed.
+ *
+ * Return 0 on success, -errno on error.
+ */
+ int (*close)(implements_net_stream_listener *self);
};
struct net_stream_conn_vtable {
@@ -119,4 +127,28 @@ struct net_packet_conn_vtable {
int (*close )(implements_net_packet_conn *self);
};
+/* Interfaces *****************************************************************/
+
+struct net_iface_config {
+ struct net_ip4_addr addr;
+ struct net_ip4_addr gateway_addr;
+ struct net_ip4_addr subnet_mask;
+};
+
+struct net_iface_vtable;
+
+typedef struct {
+ struct net_iface_vtable *vtable;
+} implements_net_iface;
+
+struct net_iface_vtable {
+ struct net_eth_addr (*hwaddr )(implements_net_iface *);
+ void (*ifup )(implements_net_iface *, struct net_iface_config);
+ void (*ifdown )(implements_net_iface *);
+
+ implements_net_stream_listener *(*tcp_listen)(implements_net_iface *, uint16_t local_port);
+ implements_net_stream_conn *(*tcp_dial )(implements_net_iface *, struct net_ip4_addr remote_node, uint16_t remote_port);
+ implements_net_packet_conn *(*udp_conn )(implements_net_iface *, uint16_t local_port);
+};
+
#endif /* _LIBHW_GENERIC_NET_H_ */