iPXE
Data Structures | Macros | Functions
portmap.h File Reference

SUN ONC RPC protocol. More...

#include <stdint.h>
#include <ipxe/oncrpc.h>

Go to the source code of this file.

Data Structures

struct  portmap_getport_reply
 A PORTMAP GETPORT reply. More...
 

Macros

#define PORTMAP_PORT   111
 PORTMAP default port. More...
 
#define ONCRPC_PORTMAP   100000
 PORTMAP protocol number. More...
 
#define PORTMAP_VERS   2
 PORTMAP version. More...
 
#define PORTMAP_PROTO_TCP   6
 TCP protocol number. More...
 
#define PORTMAP_PROTO_UDP   17
 UDB protocol number. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static void portmap_init_session (struct oncrpc_session *session, struct oncrpc_cred *credential)
 Prepare an ONC RPC session to be used as a PORTMAP session. More...
 
int portmap_getport (struct interface *intf, struct oncrpc_session *session, uint32_t prog, uint32_t vers, uint32_t proto)
 Send a GETPORT request. More...
 
int portmap_get_getport_reply (struct portmap_getport_reply *getport_reply, struct oncrpc_reply *reply)
 Parse a GETPORT reply. More...
 

Detailed Description

SUN ONC RPC protocol.

Definition in file portmap.h.

Macro Definition Documentation

◆ PORTMAP_PORT

#define PORTMAP_PORT   111

PORTMAP default port.

Definition at line 16 of file portmap.h.

◆ ONCRPC_PORTMAP

#define ONCRPC_PORTMAP   100000

PORTMAP protocol number.

Definition at line 19 of file portmap.h.

◆ PORTMAP_VERS

#define PORTMAP_VERS   2

PORTMAP version.

Definition at line 22 of file portmap.h.

◆ PORTMAP_PROTO_TCP

#define PORTMAP_PROTO_TCP   6

TCP protocol number.

Definition at line 26 of file portmap.h.

◆ PORTMAP_PROTO_UDP

#define PORTMAP_PROTO_UDP   17

UDB protocol number.

Definition at line 28 of file portmap.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ portmap_init_session()

static void portmap_init_session ( struct oncrpc_session session,
struct oncrpc_cred credential 
)
inlinestatic

Prepare an ONC RPC session to be used as a PORTMAP session.

Parameters
sessionONC RPC session
credentialONC RPC credential

The credential parameter must not be NULL, use 'oncrpc_auth_none' if you don't want a particular scheme to be used.

Definition at line 50 of file portmap.h.

51  {
54 }
#define ONCRPC_PORTMAP
PORTMAP protocol number.
Definition: portmap.h:19
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
struct ntlm_data session
Session key.
Definition: ntlm.h:24
struct oncrpc_cred oncrpc_auth_none
AUTH NONE authentication flavor.
Definition: oncrpc.c:56
#define PORTMAP_VERS
PORTMAP version.
Definition: portmap.h:22

References oncrpc_auth_none, oncrpc_init_session(), ONCRPC_PORTMAP, PORTMAP_VERS, and session.

Referenced by nfs_open().

◆ portmap_getport()

int portmap_getport ( struct interface intf,
struct oncrpc_session session,
uint32_t  prog,
uint32_t  vers,
uint32_t  proto 
)

Send a GETPORT request.

Parameters
intfInterface to send the request on
sessionONC RPC session
progONC RPC program number
versONC RPC rogram version number
protoProtocol (TCP or UDP)
Return values
rcReturn status code

Definition at line 59 of file portmap.c.

60  {
61  struct oncrpc_field fields[] = {
62  ONCRPC_FIELD ( int32, prog ),
63  ONCRPC_FIELD ( int32, vers ),
64  ONCRPC_FIELD ( int32, proto ),
65  ONCRPC_FIELD ( int32, 0 ), /* The port field is only meaningful
66  in GETPORT reply */
68  };
69 
70  return oncrpc_call ( intf, session, PORTMAP_GETPORT, fields );
71 }
#define ONCRPC_FIELD(type, value)
Definition: oncrpc.h:28
#define PORTMAP_GETPORT
PORTMAP GETPORT procedure.
Definition: portmap.c:47
int oncrpc_call(struct interface *intf, struct oncrpc_session *session, uint32_t proc_name, const struct oncrpc_field fields[])
Definition: oncrpc.c:129
int32_t int32
Definition: stdint.h:31
struct ntlm_data session
Session key.
Definition: ntlm.h:24
#define ONCRPC_FIELD_END
Definition: oncrpc.h:32

References oncrpc_call(), ONCRPC_FIELD, ONCRPC_FIELD_END, PORTMAP_GETPORT, and session.

Referenced by nfs_pm_step().

◆ portmap_get_getport_reply()

int portmap_get_getport_reply ( struct portmap_getport_reply getport_reply,
struct oncrpc_reply reply 
)

Parse a GETPORT reply.

Parameters
getport_replyA structure where the data will be saved
replyThe ONC RPC reply to get data from
Return values
rcReturn status code

Definition at line 80 of file portmap.c.

81  {
82  if ( ! getport_reply || ! reply )
83  return -EINVAL;
84 
85  getport_reply->port = oncrpc_iob_get_int ( reply->data );
86  if ( getport_reply == 0 || getport_reply->port >= 65536 )
87  return -EINVAL;
88 
89  return 0;
90 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
#define oncrpc_iob_get_int(buf)
Get a 32 bits integer from the beginning of an I/O buffer.
Definition: oncrpc_iob.h:38
uint32_t port
Port returned.
Definition: portmap.h:37
struct io_buffer * data
Definition: oncrpc.h:68

References oncrpc_reply::data, EINVAL, oncrpc_iob_get_int, and portmap_getport_reply::port.

Referenced by nfs_pm_deliver().