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 
14 FILE_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 
46 struct oncrpc_cred {
49 };
50 
54  char *hostname;
59 };
60 
62 {
68  struct io_buffer *data;
69 };
70 
78 };
79 
88 };
89 
91  struct {
92  size_t length;
93  const void *ptr;
94  } array;
95 
96  struct {
97  size_t length;
98  const uint32_t *ptr;
99  } intarray;
100 
103  const char *str;
104  const struct oncrpc_cred *cred;
105 };
106 
107 struct oncrpc_field {
110 };
111 
112 extern struct oncrpc_cred oncrpc_auth_none;
113 
114 int oncrpc_init_cred_sys ( struct oncrpc_cred_sys *auth_sys );
116  struct oncrpc_cred *credential,
117  struct oncrpc_cred *verifier, uint32_t prog_name,
118  uint32_t prog_vers );
119 
120 int oncrpc_call ( struct interface *intf, struct oncrpc_session *session,
121  uint32_t proc_name, const struct oncrpc_field fields[] );
122 
123 size_t oncrpc_compute_size ( const struct oncrpc_field fields[] );
124 
126  struct oncrpc_reply *reply, struct io_buffer *io_buf );
127 
128 #endif /* _IPXE_ONCRPC_H */
size_t oncrpc_compute_size(const struct oncrpc_field fields[])
Definition: oncrpc.c:166
struct oncrpc_cred oncrpc_auth_none
AUTH NONE authentication flavor.
Definition: oncrpc.c:56
uint32_t uid
Definition: oncrpc.h:55
struct oncrpc_cred * verifier
Definition: oncrpc.h:63
uint32_t gid
Definition: oncrpc.h:56
uint32_t prog_name
Definition: oncrpc.h:76
struct oncrpc_cred * verifier
Definition: oncrpc.h:74
int oncrpc_get_reply(struct oncrpc_session *session, struct oncrpc_reply *reply, struct io_buffer *io_buf)
I/O buffers.
size_t length
Definition: oncrpc.h:92
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
uint32_t aux_gid_len
Definition: oncrpc.h:57
uint32_t rpc_id
Definition: oncrpc.h:75
uint32_t accept_state
Definition: oncrpc.h:66
uint32_t rpc_id
Definition: oncrpc.h:64
uint32_t frame_size
Definition: oncrpc.h:67
signed long long int64_t
Definition: stdint.h:18
An object interface.
Definition: interface.h:124
union oncrpc_field_value value
Definition: oncrpc.h:109
struct ntlm_data session
Session key.
Definition: ntlm.h:24
Object interfaces.
int oncrpc_call(struct interface *intf, struct oncrpc_session *session, uint32_t proc_name, const struct oncrpc_field fields[])
Definition: oncrpc.c:129
enum oncrpc_field_type type
Definition: oncrpc.h:108
const uint32_t * ptr
Definition: oncrpc.h:98
uint32_t flavor
Definition: oncrpc.h:47
uint32_t prog_vers
Definition: oncrpc.h:77
char * hostname
Definition: oncrpc.h:54
unsigned int uint32_t
Definition: stdint.h:12
struct oncrpc_field_value::@579 intarray
int32_t int32
Definition: oncrpc.h:102
uint32_t reply_state
Definition: oncrpc.h:65
const void * ptr
Definition: oncrpc.h:93
oncrpc_field_type
Definition: oncrpc.h:80
signed int int32_t
Definition: stdint.h:17
struct oncrpc_field_value::@578 array
int oncrpc_init_cred_sys(struct oncrpc_cred_sys *auth_sys)
Initialize an ONC RPC AUTH SYS credential structure.
Definition: oncrpc.c:84
uint32_t stamp
Definition: oncrpc.h:53
const char * str
Definition: oncrpc.h:103
int64_t int64
Definition: oncrpc.h:101
uint32_t length
Definition: oncrpc.h:48
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
uint32_t aux_gid[16]
Definition: oncrpc.h:58
struct oncrpc_cred * credential
Definition: oncrpc.h:73
struct oncrpc_cred credential
Definition: oncrpc.h:52
const struct oncrpc_cred * cred
Definition: oncrpc.h:104
struct io_buffer * data
Definition: oncrpc.h:68
struct oncrpc_reply pending_reply
Definition: oncrpc.h:72
A persistent I/O buffer.
Definition: iobuf.h:33