1/* 2 * Copyright 2016, Data61 3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO) 4 * ABN 41 687 119 230. 5 * 6 * This software may be distributed and modified according to the terms of 7 * the BSD 2-Clause license. Note that NO WARRANTY is provided. 8 * See "LICENSE_BSD2.txt" for details. 9 * 10 * @TAG(D61_BSD) 11 */ 12 13#ifndef _RPC_INTERFACE_SERV_CLIENT_HELPER_H_ 14#define _RPC_INTERFACE_SERV_CLIENT_HELPER_H_ 15 16#include <stdarg.h> 17#include <refos-rpc/rpc.h> 18#include <refos/refos.h> 19#include <refos/error.h> 20#include <refos-rpc/serv_client.h> 21#include <refos-rpc/data_client.h> 22#include <refos-rpc/data_client_helper.h> 23#include <refos-rpc/name_client.h> 24#include <refos-rpc/name_client_helper.h> 25 26/*! @file 27 @brief Helper functions for the server connection interface. 28 29 This file contains a simple layer of helper functions that make using the server interface 30 much easier, but are too complex to have been generated by the stub generator. 31*/ 32 33#ifdef dvprintf 34 #define _svprintf dvprintf 35#else 36 #define _svprintf(...) 37#endif 38 39/*! @brief Struct containing the state of an open server connection session. 40 This includes the name resolve result, the session, and the set up parameter buffer. 41*/ 42typedef struct serv_connection_s { 43 int error; 44 nsv_mountpoint_t serverMountPoint; /* Has ownership. */ 45 seL4_CPtr serverSession; /* Has ownership. */ 46 data_mapping_t paramBuffer; /* Has ownership. */ 47 bool connectionLess; 48} serv_connection_t; 49 50/*! @brief Connect to server at the given path. Helper function for serv_connect_direct(). Set up 51 the parameter buffer. 52 @param serverPath The namespace path of server to connect to. 53 @return Struct containing the open server connection and param buffer info. Check the error 54 member of the struct in order to check for failure. (Gives ownership) 55*/ 56serv_connection_t serv_connect(char *serverPath); 57 58/*! @brief Connect to server at the given path. Helper function for serv_connect_direct(). Does not 59 set up a parameter buffer. 60 @param serverPath The namespace path of server to connect to. 61 @return Struct containing the open server connection and param buffer info. Check the error 62 member of the struct in order to check for failure. (Gives ownership) 63*/ 64serv_connection_t serv_connect_no_pbuffer(char *serverPath); 65 66/*! @brief Disconnect from the server, unmap and delete parameter buffer, and release the memory 67 associated. 68 @param sc The server connection state structure to disconnect. Does NOT free the structure 69 itself, only frees the resources pointed to by it. (Takes ownership) 70*/ 71void serv_disconnect(serv_connection_t *sc); 72 73#endif /* _RPC_INTERFACE_SERV_CLIENT_HELPER_H_ */