iPXE
oncrpc_iob.h
Go to the documentation of this file.
1#ifndef _IPXE_ONCRPC_IOB_H
2#define _IPXE_ONCRPC_IOB_H
3
4#include <stdint.h>
5#include <string.h>
6#include <ipxe/iobuf.h>
7#include <ipxe/refcnt.h>
8#include <ipxe/oncrpc.h>
9
10/** @file
11 *
12 * SUN ONC RPC protocol.
13 *
14 */
15
16FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
17
18/**
19 * Add a string to the end of an I/O buffer
20 *
21 * @v io_buf I/O buffer
22 * @v val String
23 * @ret size Size of the data written
24 */
25#define oncrpc_iob_add_string( buf, str ) \
26( { \
27 const char * _str = (str); \
28 oncrpc_iob_add_array ( (buf), strlen ( _str ), _str ); \
29} )
30
31/**
32 * Get a 32 bits integer from the beginning of an I/O buffer
33 *
34 * @v buf I/O buffer
35 * @ret int Integer
36 */
37
38#define oncrpc_iob_get_int( buf ) \
39( { \
40 uint32_t *_val; \
41 _val = (buf)->data; \
42 iob_pull ( (buf), sizeof ( uint32_t ) ); \
43 ntohl ( *_val ); \
44} )
45
46/**
47 * Get a 64 bits integer from the beginning of an I/O buffer
48 *
49 * @v buf I/O buffer
50 * @ret int Integer
51 */
52#define oncrpc_iob_get_int64( buf ) \
53( { \
54 uint64_t *_val; \
55 _val = (buf)->data; \
56 iob_pull ( (buf), sizeof ( uint64_t ) ); \
57 ntohll ( *_val ); \
58} )
59
60
61size_t oncrpc_iob_add_fields ( struct io_buffer *io_buf,
62 const struct oncrpc_field fields[] );
63
64size_t oncrpc_iob_add_array ( struct io_buffer *io_buf, size_t length,
65 const void *data );
66
67size_t oncrpc_iob_add_intarray ( struct io_buffer *io_buf, size_t length,
68 const uint32_t *array );
69
70size_t oncrpc_iob_add_cred ( struct io_buffer *io_buf,
71 const struct oncrpc_cred *cred );
72
73size_t oncrpc_iob_get_cred ( struct io_buffer *io_buf,
74 struct oncrpc_cred *cred );
75
76/**
77 * Add a 32 bits integer to the end of an I/O buffer
78 *
79 * @v io_buf I/O buffer
80 * @v val Integer
81 * @ret size Size of the data written
82 */
83static inline size_t oncrpc_iob_add_int ( struct io_buffer *io_buf,
84 uint32_t val ) {
85 * ( uint32_t * ) iob_put ( io_buf, sizeof ( val ) ) = htonl ( val );
86 return ( sizeof ( val) );
87}
88
89/**
90 * Add a 64 bits integer to the end of an I/O buffer
91 *
92 * @v io_buf I/O buffer
93 * @v val Integer
94 * @ret size Size of the data written
95 */
96static inline size_t oncrpc_iob_add_int64 ( struct io_buffer *io_buf,
97 uint64_t val ) {
98 * ( uint64_t * ) iob_put ( io_buf, sizeof ( val ) ) = htonll ( val );
99 return ( sizeof ( val) );
100}
101
102#endif /* _IPXE_ONCRPC_IOB_H */
unsigned int uint32_t
Definition stdint.h:12
unsigned long long uint64_t
Definition stdint.h:13
uint32_t array
Array number.
Definition edd.h:1
uint8_t data[48]
Additional event data.
Definition ena.h:11
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define htonll(value)
Definition byteswap.h:132
#define htonl(value)
Definition byteswap.h:134
String functions.
void __asmcall int val
Definition setjmp.h:12
I/O buffers.
#define iob_put(iobuf, len)
Definition iobuf.h:125
SUN ONC RPC protocol.
size_t oncrpc_iob_get_cred(struct io_buffer *io_buf, struct oncrpc_cred *cred)
Get credential information from the beginning of an I/O buffer.
Definition oncrpc_iob.c:191
size_t oncrpc_iob_add_array(struct io_buffer *io_buf, size_t length, const void *data)
Add an array of bytes to the end of an I/O buffer.
Definition oncrpc_iob.c:105
static size_t oncrpc_iob_add_int64(struct io_buffer *io_buf, uint64_t val)
Add a 64 bits integer to the end of an I/O buffer.
Definition oncrpc_iob.h:96
static size_t oncrpc_iob_add_int(struct io_buffer *io_buf, uint32_t val)
Add a 32 bits integer to the end of an I/O buffer.
Definition oncrpc_iob.h:83
size_t oncrpc_iob_add_intarray(struct io_buffer *io_buf, size_t length, const uint32_t *array)
Add an int array to the end of an I/O buffer.
Definition oncrpc_iob.c:124
size_t oncrpc_iob_add_fields(struct io_buffer *io_buf, const struct oncrpc_field fields[])
Definition oncrpc_iob.c:46
size_t oncrpc_iob_add_cred(struct io_buffer *io_buf, const struct oncrpc_cred *cred)
Add credential information to the end of an I/O buffer.
Definition oncrpc_iob.c:143
Reference counting.
u16 length
Definition sky2.h:1
A persistent I/O buffer.
Definition iobuf.h:38