iPXE
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.

Macros

#define PORTMAP_GETPORT   3
 PORTMAP GETPORT procedure.

Functions

 FILE_SECBOOT (FORBIDDEN)
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.

Macro Definition Documentation

◆ PORTMAP_GETPORT

#define PORTMAP_GETPORT   3

PORTMAP GETPORT procedure.

Definition at line 49 of file portmap.c.

Referenced by portmap_getport().

Function Documentation

◆ FILE_SECBOOT()

FILE_SECBOOT ( FORBIDDEN )

◆ 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 61 of file portmap.c.

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

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

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 82 of file portmap.c.

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

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

Referenced by nfs_pm_deliver().