iPXE
Defines | Functions
portmap.c File Reference

PORTMAPPER protocol. More...

#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/socket.h>
#include <ipxe/tcpip.h>
#include <ipxe/in.h>
#include <ipxe/iobuf.h>
#include <ipxe/xfer.h>
#include <ipxe/open.h>
#include <ipxe/uri.h>
#include <ipxe/features.h>
#include <ipxe/timer.h>
#include <ipxe/oncrpc.h>
#include <ipxe/oncrpc_iob.h>
#include <ipxe/portmap.h>

Go to the source code of this file.

Defines

#define PORTMAP_GETPORT   3
 PORTMAP GETPORT procedure.

Functions

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

PORTMAPPER protocol.

Definition in file portmap.c.


Define Documentation

#define PORTMAP_GETPORT   3

PORTMAP GETPORT procedure.

Definition at line 47 of file portmap.c.

Referenced by portmap_getport().


Function Documentation

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;
}