1 #ifndef _IPXE_ONCRPC_IOB_H
2 #define _IPXE_ONCRPC_IOB_H
6 #include <ipxe/iobuf.h>
7 #include <ipxe/refcnt.h>
8 #include <ipxe/oncrpc.h>
12 * SUN ONC RPC protocol.
16 FILE_LICENCE ( GPL2_OR_LATER );
19 * Add a string to the end of an I/O buffer
21 * @v io_buf I/O buffer
23 * @ret size Size of the data written
25 #define oncrpc_iob_add_string( buf, str ) \
27 const char * _str = (str); \
28 oncrpc_iob_add_array ( (buf), strlen ( _str ), _str ); \
32 * Get a 32 bits integer from the beginning of an I/O buffer
38 #define oncrpc_iob_get_int( buf ) \
42 iob_pull ( (buf), sizeof ( uint32_t ) ); \
47 * Get a 64 bits integer from the beginning of an I/O buffer
52 #define oncrpc_iob_get_int64( buf ) \
56 iob_pull ( (buf), sizeof ( uint64_t ) ); \
61 size_t oncrpc_iob_add_fields ( struct io_buffer *io_buf,
62 const struct oncrpc_field fields[] );
64 size_t oncrpc_iob_add_array ( struct io_buffer *io_buf, size_t length,
67 size_t oncrpc_iob_add_intarray ( struct io_buffer *io_buf, size_t length,
68 const uint32_t *array );
70 size_t oncrpc_iob_add_cred ( struct io_buffer *io_buf,
71 const struct oncrpc_cred *cred );
73 size_t oncrpc_iob_get_cred ( struct io_buffer *io_buf,
74 struct oncrpc_cred *cred );
77 * Add a 32 bits integer to the end of an I/O buffer
79 * @v io_buf I/O buffer
81 * @ret size Size of the data written
83 static inline size_t oncrpc_iob_add_int ( struct io_buffer *io_buf,
85 * ( uint32_t * ) iob_put ( io_buf, sizeof ( val ) ) = htonl ( val );
86 return ( sizeof ( val) );
90 * Add a 64 bits integer to the end of an I/O buffer
92 * @v io_buf I/O buffer
94 * @ret size Size of the data written
96 static inline size_t oncrpc_iob_add_int64 ( struct io_buffer *io_buf,
98 * ( uint64_t * ) iob_put ( io_buf, sizeof ( val ) ) = htonll ( val );
99 return ( sizeof ( val) );
102 #endif /* _IPXE_ONCRPC_IOB_H */