iPXE
Data Structures | Defines | 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...

Defines

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

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.
int portmap_getport (struct interface *intf, struct oncrpc_session *session, uint32_t prog, uint32_t vers, uint32_t proto)
 Send a GETPORT request.
int portmap_get_getport_reply (struct portmap_getport_reply *getport_reply, struct oncrpc_reply *reply)
 Parse a GETPORT reply.

Detailed Description

SUN ONC RPC protocol.

Definition in file portmap.h.


Define Documentation

#define PORTMAP_PORT   111

PORTMAP default port.

Definition at line 16 of file portmap.h.

Referenced by nfs_open().

#define ONCRPC_PORTMAP   100000

PORTMAP protocol number.

Definition at line 19 of file portmap.h.

Referenced by portmap_init_session().

#define PORTMAP_VERS   2

PORTMAP version.

Definition at line 22 of file portmap.h.

Referenced by portmap_init_session().

#define PORTMAP_PROTO_TCP   6

TCP protocol number.

Definition at line 26 of file portmap.h.

Referenced by nfs_pm_step().

#define PORTMAP_PROTO_UDP   17

UDB protocol number.

Definition at line 28 of file portmap.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static void portmap_init_session ( struct oncrpc_session session,
struct oncrpc_cred credential 
) [inline, static]

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.

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

Referenced by nfs_open().

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.

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

Referenced by nfs_pm_step().

                                                                     {
        struct oncrpc_field fields[] = {
                ONCRPC_FIELD ( int32, prog ),
                ONCRPC_FIELD ( int32, vers ),
                ONCRPC_FIELD ( int32, proto ),
                ONCRPC_FIELD ( int32, 0 ), /* The port field is only meaningful
                                              in GETPORT reply */
                ONCRPC_FIELD_END,
        };

        return oncrpc_call ( intf, session, PORTMAP_GETPORT, fields );
}
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.

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

Referenced by nfs_pm_deliver().

                                                             {
        if ( ! getport_reply || ! reply )
                return -EINVAL;

        getport_reply->port = oncrpc_iob_get_int ( reply->data );
        if ( getport_reply == 0 || getport_reply->port >= 65536 )
                return -EINVAL;

        return 0;
}