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 
16 FILE_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 
61 size_t oncrpc_iob_add_fields ( struct io_buffer *io_buf,
62  const struct oncrpc_field fields[] );
63 
64 size_t oncrpc_iob_add_array ( struct io_buffer *io_buf, size_t length,
65  const void *data );
66 
67 size_t oncrpc_iob_add_intarray ( struct io_buffer *io_buf, size_t length,
68  const uint32_t *array );
69 
70 size_t oncrpc_iob_add_cred ( struct io_buffer *io_buf,
71  const struct oncrpc_cred *cred );
72 
73 size_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  */
83 static 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  */
96 static 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 */
u16 length
Definition: sky2.h:9
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:141
#define iob_put(iobuf, len)
Definition: iobuf.h:120
I/O buffers.
unsigned long long uint64_t
Definition: stdint.h:13
#define htonl(value)
Definition: byteswap.h:133
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
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
uint32_t array
Array number.
Definition: edd.h:30
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:103
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
unsigned int uint32_t
Definition: stdint.h:12
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:122
void __asmcall int val
Definition: setjmp.h:28
#define htonll(value)
Definition: byteswap.h:131
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:189
Reference counting.
uint8_t data[48]
Additional event data.
Definition: ena.h:22
SUN ONC RPC protocol.
size_t oncrpc_iob_add_fields(struct io_buffer *io_buf, const struct oncrpc_field fields[])
Definition: oncrpc_iob.c:44
String functions.
A persistent I/O buffer.
Definition: iobuf.h:33