RTEMS  5.1
Data Structures | Macros | Typedefs | Functions | Variables
rpcio.c File Reference

RPC Multiplexor for a Multitasking Environment. More...

#include <inttypes.h>
#include <rtems.h>
#include <rtems/error.h>
#include <rtems/rtems_bsdnet.h>
#include <rtems/thread.h>
#include <stdlib.h>
#include <time.h>
#include <rpc/rpc.h>
#include <rpc/pmap_prot.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/cpuset.h>
#include "rpcio.h"
#include "nfsclient-private.h"
#include <sys/mbuf.h>
#include <rtems/rtems_bsdnet_internal.h>

Data Structures

struct  ListNodeRec_
 
struct  RpcUdpServerRec_
 
union  RpcBufU_
 
struct  RpcUdpXactRec_
 
struct  RpcUdpXactPoolRec_
 

Macros

#define MBUF_RX
 
#define MBUF_TX
 
#define RPCIOD_STACK   10000
 
#define RPCIOD_PRIO   100 /* *fallback* priority */
 
#define RPCIOD_QDEPTH   20
 
#define RPCIOD_RETX_CAP_S   3 /* seconds */
 
#define RPCIOD_DEFAULT_TIMEOUT   (&_rpc_default_timeout)
 
#define RPCIOD_REFRESH   2
 
#define RTEMS_RPC_EVENT
 
#define RPCIOD_RX_EVENT   RTEMS_EVENT_1 /* Events the RPCIOD is using/waiting for */
 
#define RPCIOD_TX_EVENT   RTEMS_EVENT_2
 
#define RPCIOD_KILL_EVENT   RTEMS_EVENT_3 /* send to the daemon to kill it */
 
#define LD_XACT_HASH   8 /* ld of the size of the transaction hash table */
 
#define DEBUG_TRACE_XACT   (1<<0)
 
#define DEBUG_EVENTS   (1<<1)
 
#define DEBUG_MALLOC   (1<<2)
 
#define DEBUG_TIMEOUT   (1<<3)
 
#define DEBUG_PACKLOSS   (1<<4) /* This introduces random, artificial packet losses to test retransmission */
 
#define DEBUG_PACKLOSS_FRACT   (0xffffffff/10)
 
#define DEBUG   (0)
 
#define RPCIOD_EPOCH_SECS   10000
 
#define ASSERT(arg)   assert(arg)
 
#define XACT_HASHS   (1<<(LD_XACT_HASH)) /* the hash table size derived from the ld */
 
#define XACT_HASH_MSK   ((XACT_HASHS)-1) /* mask to extract the hash index from a RPC-XID */
 
#define MU_LOCK(mutex)   rtems_recursive_mutex_lock(&(mutex))
 
#define MU_UNLOCK(mutex)   rtems_recursive_mutex_unlock(&(mutex))
 
#define MU_CREAT(pmutex)   rtems_recursive_mutex_init((pmutex), "RPCl")
 
#define MU_DESTROY(mutex)   rtems_recursive_mutex_destroy(&(mutex))
 
#define FIRST_ATTEMPT   0x88888888 /* some time that is never reached */
 
#define XID(ibuf)   (*(mtod((ibuf), u_long *)))
 
#define SENDTO   sendto_nocpy
 
#define MY_MALLOC   malloc
 
#define MY_CALLOC   calloc
 
#define MY_FREE   free
 
#define _KERNEL
 
#define RPCIOD_RXBUFSZ   UDPMSGSIZE
 

Typedefs

typedef rtems_interval TimeoutT
 
typedef struct ListNodeRec_ ListNodeRec
 
typedef struct ListNodeRec_ListNode
 
typedef struct RpcUdpServerRec_ RpcUdpServerRec
 
typedef union RpcBufU_ RpcBufU
 
typedef union RpcBufU_RpcBuf
 
typedef struct mbuf * RxBuf
 
typedef struct RpcUdpXactRec_ RpcUdpXactRec
 
typedef struct RpcUdpXactPoolRec_ RpcUdpXactPoolRec
 

Functions

ssize_t sendto_nocpy (int s, const void *buf, size_t buflen, int flags, const struct sockaddr *toaddr, int tolen, void *closure, void(*freeproc)(caddr_t, u_int), void(*refproc)(caddr_t, u_int))
 
enum clnt_stat rpcUdpServerCreate (struct sockaddr_in *paddr, rpcprog_t prog, rpcvers_t vers, u_long uid, u_long gid, RpcUdpServer *psrv)
 
void rpcUdpServerDestroy (RpcUdpServer s)
 
int rpcUdpStats (FILE *f)
 Dump statistics to a file (stdout if NULL);. More...
 
RpcUdpXact rpcUdpXactCreate (u_long program, u_long version, u_long size)
 
void rpcUdpXactDestroy (RpcUdpXact xact)
 
enum clnt_stat rpcUdpSend (RpcUdpXact xact, RpcUdpServer srvr, struct timeval *timeout, u_long proc, xdrproc_t xres, caddr_t pres, xdrproc_t xargs, caddr_t pargs,...)
 
enum clnt_stat rpcUdpRcv (RpcUdpXact xact)
 Wait for a transaction to complete.
 
void rpcSetXIDs (uint32_t xid)
 
int rpcUdpInit (void)
 
int rpcUdpCleanup (void)
 
enum clnt_stat rpcUdpClntCreate (struct sockaddr_in *psaddr, rpcprog_t prog, rpcvers_t vers, u_long uid, u_long gid, RpcUdpClnt *pclnt)
 
enum clnt_stat rpcUdpClntCall (RpcUdpClnt xact, u_long proc, XdrProcT xargs, CaddrT pargs, XdrProcT xres, CaddrT pres, struct timeval *timeout)
 
enum clnt_stat rpcUdpCallRp (struct sockaddr_in *psrvr, u_long prog, u_long vers, u_long proc, XdrProcT xargs, CaddrT pargs, XdrProcT xres, CaddrT pres, u_long uid, u_long gid, struct timeval *timeout)
 
RpcUdpXactPool rpcUdpXactPoolCreate (rpcprog_t prog, rpcvers_t version, int xactsize, int poolsize)
 
void rpcUdpXactPoolDestroy (RpcUdpXactPool pool)
 
RpcUdpXact rpcUdpXactPoolGet (RpcUdpXactPool pool, XactPoolGetMode mode)
 
void rpcUdpXactPoolPut (RpcUdpXact xact)
 

Variables

rtems_task_priority rpciodPriority = 0
 

Detailed Description

RPC Multiplexor for a Multitasking Environment.

This code funnels arbitrary task's UDP/RPC requests through one socket to arbitrary servers. The replies are gathered and dispatched to the requestors. One task handles all the sending and receiving work including retries. It is up to the requestor, however, to do the XDR encoding of the arguments / decoding of the results (except for the RPC header which is handled by the daemon).

Macro Definition Documentation

◆ MBUF_RX

#define MBUF_RX
Value:
/* If defined: use mbuf XDR stream for
* decoding directly out of mbufs
* Otherwise, the regular 'recvfrom()'
* interface will be used involving an
* extra buffer allocation + copy step.
*/

◆ MBUF_TX

#define MBUF_TX
Value:
/* If defined: avoid copying data when
* sending. Instead, use a wrapper to
* 'sosend()' which will point an MBUF
* directly to our buffer space.
* Note that the BSD stack does not copy
* data when fragmenting packets - it
* merely uses an mbuf chain pointing
* into different areas of the data.
*
* If undefined, the regular 'sendto()'
* interface is used.
*/

◆ RTEMS_RPC_EVENT

#define RTEMS_RPC_EVENT
Value:
RTEMS_EVENT_30 /* THE event used by RPCIO. Every task doing
* RPC IO will receive this - hence it is
* RESERVED
*/
#define RTEMS_EVENT_30
Defines the bit in the event set associated with event 30.
Definition: event.h:108