diff options
Diffstat (limited to 'libhw/common_include')
-rw-r--r-- | libhw/common_include/libhw/generic/net.h | 32 |
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_ */ |