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

Macros

#define PORTMAP_GETPORT   3
 PORTMAP GETPORT procedure. More...
 

Functions

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

PORTMAPPER protocol.

Definition in file portmap.c.

Macro Definition Documentation

◆ PORTMAP_GETPORT

#define PORTMAP_GETPORT   3

PORTMAP GETPORT procedure.

Definition at line 47 of file portmap.c.

Function Documentation

◆ 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().