MOS Source Code
Loading...
Searching...
No Matches
rpc_client.h File Reference
#include <librpc/rpc.h>
#include <mos/types.h>
#include <stdarg.h>
+ Include dependency graph for rpc_client.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  rpc_result_t
 

Macros

#define rpc_pb_call(stub, funcid, reqt, req, respt, resp)
 

Typedefs

typedef struct rpc_server_stub rpc_server_stub_t
 
typedef struct rpc_call rpc_call_t
 

Functions

MOSAPI rpc_server_stub_trpc_client_create (const char *server_name)
 Create a new RPC client stub for the given server.
 
MOSAPI void rpc_client_destroy (rpc_server_stub_t *server)
 Destroy a server stub.
 
MOSAPI rpc_result_code_t rpc_simple_call (rpc_server_stub_t *stub, u32 funcid, rpc_result_t *result, const char *argspec,...)
 Call a function on the server.
 
MOSAPI rpc_result_code_t rpc_simple_callv (rpc_server_stub_t *stub, u32 funcid, rpc_result_t *result, const char *argspec, va_list args)
 Call a function on the server.
 
MOSAPI rpc_call_trpc_call_create (rpc_server_stub_t *server, u32 function_id)
 Manually create a new RPC call.
 
MOSAPI void rpc_call_arg (rpc_call_t *call, rpc_argtype_t argtype, const void *data, size_t size)
 Add an argument to a call.
 
MOSAPI void rpc_call_arg_u8 (rpc_call_t *call, u8 arg)
 
MOSAPI void rpc_call_arg_u16 (rpc_call_t *call, u16 arg)
 
MOSAPI void rpc_call_arg_u32 (rpc_call_t *call, u32 arg)
 
MOSAPI void rpc_call_arg_u64 (rpc_call_t *call, u64 arg)
 
MOSAPI void rpc_call_arg_s8 (rpc_call_t *call, s8 arg)
 
MOSAPI void rpc_call_arg_s16 (rpc_call_t *call, s16 arg)
 
MOSAPI void rpc_call_arg_s32 (rpc_call_t *call, s32 arg)
 
MOSAPI void rpc_call_arg_s64 (rpc_call_t *call, s64 arg)
 
MOSAPI void rpc_call_arg_string (rpc_call_t *call, const char *arg)
 
MOSAPI rpc_result_code_t rpc_call_exec (rpc_call_t *call, void **result_data, size_t *result_size)
 Execute a call.
 
MOSAPI void rpc_call_destroy (rpc_call_t *call)
 Destroy a call.
 
MOSAPI rpc_result_code_t rpc_do_pb_call (rpc_server_stub_t *stub, u32 funcid, const pb_msgdesc_t *reqm, const void *req, const pb_msgdesc_t *respm, void *resp)
 Call a function on the server using protobuf (nanopb)
 

Macro Definition Documentation

◆ rpc_pb_call

#define rpc_pb_call ( stub,
funcid,
reqt,
req,
respt,
resp )
Value:
rpc_do_pb_call(stub, funcid, reqt##_fields, req, respt##_fields, resp)
MOSAPI rpc_result_code_t rpc_do_pb_call(rpc_server_stub_t *stub, u32 funcid, const pb_msgdesc_t *reqm, const void *req, const pb_msgdesc_t *respm, void *resp)
Call a function on the server using protobuf (nanopb)
Definition rpc_client.c:298

Definition at line 125 of file rpc_client.h.

Typedef Documentation

◆ rpc_server_stub_t

typedef struct rpc_server_stub rpc_server_stub_t

Definition at line 10 of file rpc_client.h.

◆ rpc_call_t

typedef struct rpc_call rpc_call_t

Definition at line 11 of file rpc_client.h.

Function Documentation

◆ rpc_client_create()

MOSAPI rpc_server_stub_t * rpc_client_create ( const char * server_name)

Create a new RPC client stub for the given server.

Parameters
server_nameThe name of the server to connect to
Returns
rpc_server_stub_t* A pointer to the new server stub, or NULL on error

Definition at line 65 of file rpc_client.c.

Referenced by userfs_ensure_connected().

+ Here is the call graph for this function:

◆ rpc_client_destroy()

MOSAPI void rpc_client_destroy ( rpc_server_stub_t * server)

Destroy a server stub.

Parameters
serverThe server stub to destroy

Definition at line 81 of file rpc_client.c.

+ Here is the call graph for this function:

◆ rpc_simple_call()

MOSAPI rpc_result_code_t rpc_simple_call ( rpc_server_stub_t * stub,
u32 funcid,
rpc_result_t * result,
const char * argspec,
... )

Call a function on the server.

Parameters
stubThe server stub to call
funcidThe function ID to call
resultA pointer to a result structure, or NULL if no result is expected
argspecAn argument specification string, see spec.md for details
...The arguments to the function
Returns
rpc_result_code_t The result code of the call
Note
The result data will be malloc'd and must be freed by the caller.
This function is a simple wrapper around rpc_call_create, rpc_call_arg, rpc_call_exec and rpc_call_destroy.

Definition at line 222 of file rpc_client.c.

+ Here is the call graph for this function:

◆ rpc_simple_callv()

MOSAPI rpc_result_code_t rpc_simple_callv ( rpc_server_stub_t * stub,
u32 funcid,
rpc_result_t * result,
const char * argspec,
va_list args )

Call a function on the server.

Parameters
stubThe server stub to call
funcidThe function ID to call
resultA pointer to a result structure, or NULL if no result is expected
argspecAn argument specification string, see spec.md for details
argsThe arguments to the function
Returns
rpc_result_code_t The result code of the call

Definition at line 231 of file rpc_client.c.

Referenced by rpc_simple_call().

+ Here is the call graph for this function:

◆ rpc_call_create()

MOSAPI rpc_call_t * rpc_call_create ( rpc_server_stub_t * server,
u32 function_id )

Manually create a new RPC call.

Parameters
serverThe server stub to call
function_idThe function ID to call
Returns
rpc_call_t* A pointer to the new call.

Definition at line 88 of file rpc_client.c.

Referenced by rpc_do_pb_call(), and rpc_simple_callv().

◆ rpc_call_arg()

MOSAPI void rpc_call_arg ( rpc_call_t * call,
rpc_argtype_t argtype,
const void * data,
size_t size )

Add an argument to a call.

Parameters
callThe call to add the argument to
argtypeThe type of the argument
dataA pointer to the argument data
sizeThe size of the argument data

Definition at line 110 of file rpc_client.c.

Referenced by rpc_call_arg_string(), rpc_do_pb_call(), and rpc_simple_callv().

+ Here is the call graph for this function:

◆ rpc_call_arg_u8()

MOSAPI void rpc_call_arg_u8 ( rpc_call_t * call,
u8 arg )

Definition at line 132 of file rpc_client.c.

◆ rpc_call_arg_u16()

MOSAPI void rpc_call_arg_u16 ( rpc_call_t * call,
u16 arg )

◆ rpc_call_arg_u32()

MOSAPI void rpc_call_arg_u32 ( rpc_call_t * call,
u32 arg )

Definition at line 133 of file rpc_client.c.

◆ rpc_call_arg_u64()

MOSAPI void rpc_call_arg_u64 ( rpc_call_t * call,
u64 arg )

Definition at line 134 of file rpc_client.c.

◆ rpc_call_arg_s8()

MOSAPI void rpc_call_arg_s8 ( rpc_call_t * call,
s8 arg )

Definition at line 135 of file rpc_client.c.

◆ rpc_call_arg_s16()

MOSAPI void rpc_call_arg_s16 ( rpc_call_t * call,
s16 arg )

◆ rpc_call_arg_s32()

MOSAPI void rpc_call_arg_s32 ( rpc_call_t * call,
s32 arg )

Definition at line 136 of file rpc_client.c.

◆ rpc_call_arg_s64()

MOSAPI void rpc_call_arg_s64 ( rpc_call_t * call,
s64 arg )

Definition at line 137 of file rpc_client.c.

◆ rpc_call_arg_string()

MOSAPI void rpc_call_arg_string ( rpc_call_t * call,
const char * arg )

Definition at line 139 of file rpc_client.c.

+ Here is the call graph for this function:

◆ rpc_call_exec()

MOSAPI rpc_result_code_t rpc_call_exec ( rpc_call_t * call,
void ** result_data,
size_t * result_size )

Execute a call.

Parameters
callThe call to execute
result_dataA pointer to a pointer to the result data, or NULL if no result is expected
result_sizeA pointer to the size of the result data, or NULL if no result is expected
Returns
rpc_result_code_t The result code of the call
Note
The result data will be malloc'd and must be freed by the caller.

Definition at line 144 of file rpc_client.c.

Referenced by rpc_do_pb_call(), and rpc_simple_callv().

+ Here is the call graph for this function:

◆ rpc_call_destroy()

MOSAPI void rpc_call_destroy ( rpc_call_t * call)

Destroy a call.

Parameters
callThe call to destroy

Definition at line 103 of file rpc_client.c.

Referenced by rpc_do_pb_call(), and rpc_simple_callv().

◆ rpc_do_pb_call()

MOSAPI rpc_result_code_t rpc_do_pb_call ( rpc_server_stub_t * stub,
u32 funcid,
const pb_msgdesc_t * reqm,
const void * req,
const pb_msgdesc_t * respm,
void * resp )

Call a function on the server using protobuf (nanopb)

Parameters
stubThe server stub to call
funcidThe function ID to call
reqmThe protobuf message descriptor for the request
reqThe request message
respmThe protobuf message descriptor for the response
respThe response message
Returns
rpc_result_code_t

Definition at line 298 of file rpc_client.c.

+ Here is the call graph for this function: