iPXE
oncrpc.h
Go to the documentation of this file.
1#ifndef _IPXE_ONCRPC_H
2#define _IPXE_ONCRPC_H
3
4#include <stdint.h>
5#include <ipxe/interface.h>
6#include <ipxe/iobuf.h>
7
8/** @file
9 *
10 * SUN ONC RPC protocol.
11 *
12 */
13
14FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
15
16/** ONC RCP Version */
17#define ONCRPC_VERS 2
18
19/** ONC RPC Null Authentication */
20#define ONCRPC_AUTH_NONE 0
21
22/** ONC RPC System Authentication (also called UNIX Authentication) */
23#define ONCRPC_AUTH_SYS 1
24
25/** Size of an ONC RPC header */
26#define ONCRPC_HEADER_SIZE ( 11 * sizeof ( uint32_t ) )
27
28#define ONCRPC_FIELD( type, value ) { oncrpc_ ## type, { .type = value } }
29#define ONCRPC_SUBFIELD( type, args... ) \
30 { oncrpc_ ## type, { .type = { args } } }
31
32#define ONCRPC_FIELD_END { oncrpc_none, { } }
33
34/** Enusure that size is a multiple of four */
35#define oncrpc_align( size ) ( ( (size) + 3 ) & ~3 )
36
37/**
38 * Calculate the length of a string, including padding bytes.
39 *
40 * @v str String
41 * @ret size Length of the padded string
42 */
43#define oncrpc_strlen( str ) ( oncrpc_align ( strlen ( str ) ) + \
44 sizeof ( uint32_t ) )
45
50
60
70
79
89
91 struct {
92 size_t length;
93 const void *ptr;
95
96 struct {
97 size_t length;
98 const uint32_t *ptr;
100
103 const char *str;
104 const struct oncrpc_cred *cred;
105};
106
111
112extern struct oncrpc_cred oncrpc_auth_none;
113
114int oncrpc_init_cred_sys ( struct oncrpc_cred_sys *auth_sys );
115void oncrpc_init_session ( struct oncrpc_session *session,
116 struct oncrpc_cred *credential,
117 struct oncrpc_cred *verifier, uint32_t prog_name,
118 uint32_t prog_vers );
119
120int oncrpc_call ( struct interface *intf, struct oncrpc_session *session,
121 uint32_t proc_name, const struct oncrpc_field fields[] );
122
123size_t oncrpc_compute_size ( const struct oncrpc_field fields[] );
124
125int oncrpc_get_reply ( struct oncrpc_session *session,
126 struct oncrpc_reply *reply, struct io_buffer *io_buf );
127
128#endif /* _IPXE_ONCRPC_H */
unsigned int uint32_t
Definition stdint.h:12
signed int int32_t
Definition stdint.h:17
signed long long int64_t
Definition stdint.h:18
uint32_t array
Array number.
Definition edd.h:1
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
Object interfaces.
I/O buffers.
struct oncrpc_cred oncrpc_auth_none
AUTH NONE authentication flavor.
Definition oncrpc.c:56
oncrpc_field_type
Definition oncrpc.h:80
@ oncrpc_none
Definition oncrpc.h:81
@ oncrpc_str
Definition oncrpc.h:84
@ oncrpc_int64
Definition oncrpc.h:83
@ oncrpc_array
Definition oncrpc.h:85
@ oncrpc_intarray
Definition oncrpc.h:86
@ oncrpc_int32
Definition oncrpc.h:82
void oncrpc_init_session(struct oncrpc_session *session, struct oncrpc_cred *credential, struct oncrpc_cred *verifier, uint32_t prog_name, uint32_t prog_vers)
Prepare an ONC RPC session structure to be used by the ONC RPC layer.
Definition oncrpc.c:115
int oncrpc_call(struct interface *intf, struct oncrpc_session *session, uint32_t proc_name, const struct oncrpc_field fields[])
Definition oncrpc.c:129
size_t oncrpc_compute_size(const struct oncrpc_field fields[])
Definition oncrpc.c:166
int oncrpc_init_cred_sys(struct oncrpc_cred_sys *auth_sys)
Initialize an ONC RPC AUTH SYS credential structure.
Definition oncrpc.c:84
int oncrpc_get_reply(struct oncrpc_session *session, struct oncrpc_reply *reply, struct io_buffer *io_buf)
u16 length
Definition sky2.h:1
An object interface.
Definition interface.h:125
A persistent I/O buffer.
Definition iobuf.h:38
uint32_t aux_gid[16]
Definition oncrpc.h:58
uint32_t uid
Definition oncrpc.h:55
uint32_t aux_gid_len
Definition oncrpc.h:57
char * hostname
Definition oncrpc.h:54
uint32_t stamp
Definition oncrpc.h:53
uint32_t gid
Definition oncrpc.h:56
struct oncrpc_cred credential
Definition oncrpc.h:52
uint32_t flavor
Definition oncrpc.h:47
uint32_t length
Definition oncrpc.h:48
union oncrpc_field_value value
Definition oncrpc.h:109
enum oncrpc_field_type type
Definition oncrpc.h:108
uint32_t reply_state
Definition oncrpc.h:65
uint32_t accept_state
Definition oncrpc.h:66
uint32_t frame_size
Definition oncrpc.h:67
uint32_t rpc_id
Definition oncrpc.h:64
struct io_buffer * data
Definition oncrpc.h:68
struct oncrpc_cred * verifier
Definition oncrpc.h:63
struct oncrpc_cred * credential
Definition oncrpc.h:73
uint32_t prog_name
Definition oncrpc.h:76
struct oncrpc_cred * verifier
Definition oncrpc.h:74
uint32_t rpc_id
Definition oncrpc.h:75
uint32_t prog_vers
Definition oncrpc.h:77
struct oncrpc_reply pending_reply
Definition oncrpc.h:72
const void * ptr
Definition oncrpc.h:93
const struct oncrpc_cred * cred
Definition oncrpc.h:104
const char * str
Definition oncrpc.h:103
struct oncrpc_field_value::@354102135233215170057366227240277107100057121015 intarray