diff options
Diffstat (limited to 'libhw_generic/include')
-rw-r--r-- | libhw_generic/include/libhw/generic/io.h | 28 | ||||
-rw-r--r-- | libhw_generic/include/libhw/generic/net.h | 2 |
2 files changed, 27 insertions, 3 deletions
diff --git a/libhw_generic/include/libhw/generic/io.h b/libhw_generic/include/libhw/generic/io.h index a7f7378..7825c9f 100644 --- a/libhw_generic/include/libhw/generic/io.h +++ b/libhw_generic/include/libhw/generic/io.h @@ -8,6 +8,7 @@ #define _LIBHW_GENERIC_IO_H_ #include <stddef.h> /* for size_t */ +#include <stdint.h> /* for uintptr_t */ #include <sys/types.h> /* for ssize_t */ #include <libobj/obj.h> @@ -23,12 +24,35 @@ struct iovec { }; #endif +#define IOVEC_DISCARD ((void*)(~((uintptr_t)0))) + struct duplex_iovec { - void *iov_read_dst; - void *iov_write_src; + /** + * NULL is a valid pointer value in iov_read_to and + * iov_write_from. To skip a read or write, use the special + * value IOVEC_DISCARD. + */ + void *iov_read_to; + void *iov_write_from; size_t iov_len; }; +/* utilities ******************************************************************/ + +/* slice iovec lists */ +int io_slice_cnt ( const struct iovec *src, int src_cnt, size_t byte_start, size_t byte_max_cnt); +void io_slice (struct iovec *dst, const struct iovec *src, int src_cnt, size_t byte_start, size_t byte_max_cnt); +int io_duplex_slice_cnt( const struct duplex_iovec *src, int src_cnt, size_t byte_start, size_t byte_max_cnt); +void io_duplex_slice (struct duplex_iovec *dst, const struct duplex_iovec *src, int src_cnt, size_t byte_start, size_t byte_max_cnt); + +/* convert iovec lists */ +void io_rd_to_duplex(struct duplex_iovec *dst, const struct iovec *src, int iovcnt); +void io_wr_to_duplex(struct duplex_iovec *dst, const struct iovec *src, int iovcnt); + +/* slice and convert in one go */ +void io_slice_rd_to_duplex(struct duplex_iovec *dst, const struct iovec *src, int src_cnt, size_t byte_start, size_t byte_max_cnt); +void io_slice_wr_to_duplex(struct duplex_iovec *dst, const struct iovec *src, int src_cnt, size_t byte_start, size_t byte_max_cnt); + /* basic interfaces ***********************************************************/ /** diff --git a/libhw_generic/include/libhw/generic/net.h b/libhw_generic/include/libhw/generic/net.h index 2703b26..e88d705 100644 --- a/libhw_generic/include/libhw/generic/net.h +++ b/libhw_generic/include/libhw/generic/net.h @@ -135,7 +135,7 @@ struct net_iface_config { LO_FUNC(struct net_eth_addr , hwaddr ) \ LO_FUNC(void , ifup , struct net_iface_config) \ LO_FUNC(void , ifdown ) \ - \ + \ LO_FUNC(lo_interface net_stream_listener, tcp_listen, uint16_t local_port) \ LO_FUNC(lo_interface net_stream_conn , tcp_dial , struct net_ip4_addr remote_node, uint16_t remote_port) \ LO_FUNC(lo_interface net_packet_conn , udp_conn , uint16_t local_port) |