Annotation of libaitrpc/inc/aitrpc.h, revision 1.1.1.1.2.10

1.1       misho       1: /*************************************************************************
                      2: * (C) 2010 AITNET ltd - Sofia/Bulgaria - <misho@aitbg.com>
                      3: *  by Michael Pounov <misho@openbsd-bg.org>
                      4: *
                      5: * $Author: misho $
1.1.1.1.2.10! misho       6: * $Id: aitrpc.h,v 1.1.1.1.2.9 2010/06/23 17:29:07 misho Exp $
1.1       misho       7: *
                      8: *************************************************************************/
                      9: #ifndef __AITRPC_H
                     10: #define __AITRPC_H
                     11: 
                     12: 
                     13: #include <assert.h>
                     14: #include <stdlib.h>
                     15: #include <string.h>
                     16: #include <sys/types.h>
                     17: #include <sys/param.h>
                     18: #include <sys/limits.h>
                     19: #include <sys/socket.h>
                     20: 
                     21: 
                     22: #define RPC_VERSION            1
                     23: #define RPC_DEFPORT            2611
                     24: 
                     25: 
                     26: /* RPC builtin registed calls */
                     27: 
1.1.1.1.2.5  misho      28: #define CALL_BLOBSHUTDOWN      "rpcBLOBServerShutdown"
                     29: #define CALL_BLOBCLIENTS       "rpcBLOBServerClients"
                     30: #define CALL_BLOBVARS          "rpcBLOBServerVars"
                     31: 
1.1.1.1.2.1  misho      32: #define CALL_SRVSHUTDOWN       "rpcServerShutdown"
1.1       misho      33: #define CALL_SRVCLIENTS                "rpcServerClients"
                     34: #define CALL_SRVCALLS          "rpcServerCalls"
                     35: #define CALL_SRVSESSIONS       "rpcServerSessions"
                     36: 
                     37: 
                     38: /* RPC types */
                     39: 
                     40: typedef enum {
                     41:        empty,                          // empty -> variable is not set
1.1.1.1.2.3  misho      42:        buffer, string, blob,           // buffer -> uint8_t*; string -> int8_t*; blob -> void*(+socket);
1.1       misho      43:        size, offset, datetime,         // size -> size_t; offset -> off_t; datetime -> time_t;
                     44:        real, bigreal,                  // real -> float; bigreal -> double;
                     45:        u8, u16, u32, u64,              // unsigned integers ...
                     46:        i8, i16, i32, i64               // integers ...
                     47: } rpc_type_t;
                     48: 
1.1.1.1.2.6  misho      49: typedef enum {
1.1.1.1.2.8  misho      50:        disable, enable,                // for blob.state
                     51:        ok, error,                      // for blob reply
                     52:        get, set, unset                 // for blob request
1.1.1.1.2.6  misho      53: } cmd_type_t;
                     54: 
1.1       misho      55: /* RPC value */
                     56: 
                     57: typedef struct {
                     58:        rpc_type_t      val_type;
                     59:        size_t          val_len;
                     60:        union {
                     61:                uint8_t         *buffer;
                     62:                int8_t          *string;
1.1.1.1.2.3  misho      63:                void            *blob;
1.1       misho      64:                size_t          size;
                     65:                off_t           offset;
                     66:                time_t          datetime;
                     67:                float           real;
                     68:                double          bigreal;
                     69:                uint8_t         u8;
                     70:                uint16_t        u16;
                     71:                uint32_t        u32;
                     72:                uint64_t        u64;
                     73:                int8_t          i8;
                     74:                int16_t         i16;
                     75:                int32_t         i32;
                     76:                int64_t         i64;
                     77:        } val;
                     78: } __packed rpc_val_t;
                     79: 
                     80: #define RPC_TYPE_VAL(vl)               ((vl)->val_type)
                     81: #define RPC_LEN_VAL(vl)                        ((vl)->val_len)
1.1.1.1.2.3  misho      82: #define RPC_BLOB_CHUNKS(vl, n)         ((vl)->val_len / (n) + ((vl)->val_len % (n)) ? 1 : 0)
1.1       misho      83: #define RPC_EMPTY_VAL(vl)              ((vl)->val_type == empty)
                     84: 
                     85: #define RPC_GET_BUF(vl)                        (assert((vl)->val_type == buffer), (vl)->val.buffer)
                     86: #define RPC_GET_STR(vl)                        (assert((vl)->val_type == string), (vl)->val.string)
1.1.1.1.2.3  misho      87: #define RPC_GET_BLOB(vl)               (assert((vl)->val_type == blob), (vl)->val.blob)
1.1       misho      88: #define RPC_GET_SIZE(vl)               (assert((vl)->val_type == size), (vl)->val.size)
                     89: #define RPC_GET_OFF(vl)                        (assert((vl)->val_type == offset), (vl)->val.offset)
                     90: #define RPC_GET_TIME(vl)               (assert((vl)->val_type == datetime), (vl)->val.datetime)
                     91: #define RPC_GET_REAL(vl)               (assert((vl)->val_type == real), (vl)->val.real)
                     92: #define RPC_GET_BREAL(vl)              (assert((vl)->val_type == bigreal), (vl)->val.bigreal)
                     93: #define RPC_GET_U8(vl)                 (assert((vl)->val_type == u8), (vl)->val.u8)
                     94: #define RPC_GET_U16(vl)                        (assert((vl)->val_type == u16), (vl)->val.u16)
                     95: #define RPC_GET_U32(vl)                        (assert((vl)->val_type == u32), (vl)->val.u32)
                     96: #define RPC_GET_U64(vl)                        (assert((vl)->val_type == u64), (vl)->val.u64)
                     97: #define RPC_GET_I8(vl)                 (assert((vl)->val_type == i8), (vl)->val.i8)
                     98: #define RPC_GET_I16(vl)                        (assert((vl)->val_type == i16), (vl)->val.i16)
                     99: #define RPC_GET_I32(vl)                        (assert((vl)->val_type == i32), (vl)->val.i32)
                    100: #define RPC_GET_I64(vl)                        (assert((vl)->val_type == i64), (vl)->val.i64)
                    101: 
                    102: #define RPC_SET_BUF(vl, v, l)          do { rpc_val_t *val = (vl); assert(val); val->val.buffer = malloc(l); \
                    103:                                                if (val->val.buffer) { \
                    104:                                                        val->val_type = buffer; val->val_len = l; \
                    105:                                                        memcpy(val->val.buffer, v, l); \
                    106:                                                } } while (0)
                    107: #define RPC_SET_STR(vl, v)             do { rpc_val_t *val = (vl); assert(val); val->val.string = (int8_t*) strdup(v); \
                    108:                                                if (val->val.string) { \
                    109:                                                        val->val_type = string; val->val_len = strlen(v) + 1; \
                    110:                                                } } while (0)
1.1.1.1.2.10! misho     111: #define RPC_SET_BLOB(vl, v, l)         do { rpc_val_t *val = (vl); assert(val); val->val_type = blob; \
        !           112:                                                val->val.blob = (void*) v; val->val_len = l; } while (0)
1.1       misho     113: #define RPC_SET_SIZE(vl, v)            do { rpc_val_t *val = (vl); assert(val); val->val_type = size; val->val.size = v; \
                    114:                                                val->val_len = sizeof(size_t); } while (0)
                    115: #define RPC_SET_OFF(vl, v)             do { rpc_val_t *val = (vl); assert(val); val->val_type = offset; val->val.offset = v; \
                    116:                                                val->val_len = sizeof(off_t); } while (0)
                    117: #define RPC_SET_TIME(vl, v)            do { rpc_val_t *val = (vl); assert(val); val->val_type = datetime; val->val.datetime = v; \
                    118:                                                val->val_len = sizeof(time_t); } while (0)
                    119: #define RPC_SET_REAL(vl, v)            do { rpc_val_t *val = (vl); assert(val); val->val_type = real; val->val.real = v; \
                    120:                                                val->val_len = sizeof(float); } while (0)
                    121: #define RPC_SET_BREAL(vl, v)           do { rpc_val_t *val = (vl); assert(val); val->val_type = bigreal; val->val.bigreal = v; \
                    122:                                                val->val_len = sizeof(double); } while (0)
                    123: #define RPC_SET_U8(vl, v)              do { rpc_val_t *val = (vl); assert(val); val->val_type = u8; val->val.u8 = v; \
                    124:                                                val->val_len = sizeof(uint8_t); } while (0)
                    125: #define RPC_SET_U16(vl, v)             do { rpc_val_t *val = (vl); assert(val); val->val_type = u16; val->val.u16 = v; \
                    126:                                                val->val_len = sizeof(uint16_t); } while (0)
                    127: #define RPC_SET_U32(vl, v)             do { rpc_val_t *val = (vl); assert(val); val->val_type = u32; val->val.u32 = v; \
                    128:                                                val->val_len = sizeof(uint32_t); } while (0)
                    129: #define RPC_SET_U64(vl, v)             do { rpc_val_t *val = (vl); assert(val); val->val_type = u64; val->val.u64 = v; \
                    130:                                                val->val_len = sizeof(uint64_t); } while (0)
                    131: #define RPC_SET_I8(vl, v)              do { rpc_val_t *val = (vl); assert(val); val->val_type = i8; val->val.i8 = v; \
                    132:                                                val->val_len = sizeof(int8_t); } while (0)
                    133: #define RPC_SET_I16(vl, v)             do { rpc_val_t *val = (vl); assert(val); val->val_type = i16; val->val.i16 = v; \
                    134:                                                val->val_len = sizeof(int16_t); } while (0)
                    135: #define RPC_SET_I32(vl, v)             do { rpc_val_t *val = (vl); assert(val); val->val_type = i32; val->val.i32 = v; \
                    136:                                                val->val_len = sizeof(int32_t); } while (0)
                    137: #define RPC_SET_I64(vl, v)             do { rpc_val_t *val = (vl); assert(val); val->val_type = i64; val->val.i64 = v; \
                    138:                                                val->val_len = sizeof(int64_t); } while (0)
                    139: 
                    140: #define RPC_FREE_VAL(vl)               do { rpc_val_t *val = (vl); assert(val); \
                    141:                                                if (val->val_type == buffer && val->val.buffer) { \
                    142:                                                        free(val->val.buffer); \
                    143:                                                        val->val.buffer = NULL; \
                    144:                                                } \
                    145:                                                if (val->val_type == string && val->val.string) { \
                    146:                                                        free(val->val.string); \
                    147:                                                        val->val.string = NULL; \
                    148:                                                } \
                    149:                                                val->val_type = val->val_len = 0; \
                    150:                                        } while (0)
                    151: 
                    152: 
1.1.1.1.2.2  misho     153: #define RPC_CALLBACK_CHK_NUM_ARGS(f, n)        do { \
1.1       misho     154:                                                if (f->func_args != n) { \
                    155:                                                        rpc_SetErr(22, "Error:: different number of arguments!\n"); \
                    156:                                                        return -1; \
                    157:                                                } \
1.1.1.1.2.1  misho     158:                                        } while (0)
                    159: #define RPC_CALLBACK_CHECK_INPUT(s, f) do { \
                    160:                                                if (!s || !f) { \
                    161:                                                        rpc_SetErr(22, "Error:: invalid callback parameters ...\n"); \
                    162:                                                        return -1; \
                    163:                                                } \
                    164:                                        } while (0)
1.1       misho     165: 
                    166: 
                    167: /* RPC session identification */
                    168: 
                    169: typedef struct {
                    170:        uint8_t         sess_version;
                    171:        uint32_t        sess_program;
                    172:        uint32_t        sess_process;
                    173: } __packed rpc_sess_t;
                    174: 
                    175: 
                    176: /* Server managment RPC functions ... */
                    177: 
                    178: // RPC function registration element!
                    179: typedef struct tagRPCFunc {
                    180:        uint16_t                func_tag;
                    181:        uint32_t                func_hash;
                    182:        int8_t                  func_file[MAXPATHLEN];
                    183:        int8_t                  func_name[UCHAR_MAX + 1];
                    184: 
                    185:        int8_t                  func_args;
                    186:        rpc_val_t               *func_vals;
                    187: 
                    188:        struct tagRPCFunc       *func_next;
                    189: } rpc_func_t;
                    190: 
                    191: 
                    192: /* Network RPC packet - Client request */
                    193: 
                    194: struct tagRPCCall {
                    195:        rpc_sess_t      call_session;
                    196:        uint16_t        call_tag;
                    197:        uint32_t        call_hash;
                    198:        uint8_t         call_argc;
                    199: } __packed;
                    200: 
                    201: /* Network RPC packet - Server response */
                    202: 
                    203: struct tagRPCRet {
                    204:        rpc_sess_t      ret_session;
                    205:        uint16_t        ret_tag;
                    206:        uint32_t        ret_hash;
                    207:        int32_t         ret_retcode;
                    208:        int32_t         ret_errno;
                    209:        uint8_t         ret_argc;
                    210: } __packed;
                    211: 
1.1.1.1.2.6  misho     212: /* Network BLOB packet - Header */
                    213: 
                    214: struct tagBLOBHdr {
                    215:        rpc_sess_t      hdr_session;
                    216:        uint8_t         hdr_cmd;
                    217:        uint32_t        hdr_var;
                    218:        uint32_t        hdr_seq;
                    219:        uint32_t        hdr_len;
                    220: } __packed;
                    221: 
1.1       misho     222: /* Network RPC client & server elements */
                    223: 
                    224: typedef struct {
                    225:        struct sockaddr cli_sa;         // host info
                    226:        int             cli_sock;       // socket
                    227:        pthread_t       cli_tid;        // TID of thread
                    228: 
                    229:        void            *cli_parent;    // pointer to parent rpc_srv_t for server or to rpc_sess_t for client
                    230: } rpc_cli_t;
                    231: 
                    232: 
1.1.1.1.2.5  misho     233: // BLOB registration element!
                    234: typedef struct tagBLOB {
1.1.1.1.2.6  misho     235:        uint32_t        blob_var;
                    236: 
1.1.1.1.2.5  misho     237:        size_t          blob_len;       // size of allocated BLOB data
                    238:        void            *blob_data;     // BLOB data
                    239: 
                    240:        struct tagBLOB  *blob_next;
                    241: } rpc_blob_t;
                    242: 
                    243: typedef struct {
1.1       misho     244:        rpc_sess_t      srv_session;    // RPC session registration info
1.1.1.1.2.5  misho     245:        int             srv_numcli;     // maximum concurent client connections
1.1       misho     246: 
1.1.1.1.2.5  misho     247:        rpc_cli_t       srv_server;     // RPC server socket
                    248:        rpc_cli_t       *srv_clients;   // connected rpc client sockets
1.1       misho     249: 
                    250:        rpc_func_t      *srv_funcs;     // registered functions list
1.1.1.1.2.5  misho     251: 
                    252:        pthread_mutex_t srv_mtx;
                    253: 
                    254:        struct {
                    255:                int             state;          // BLOB server state: ==0 disable | !=0 enable
1.1.1.1.2.6  misho     256:                char            dir[UCHAR_MAX + 1];
1.1.1.1.2.5  misho     257: 
                    258:                rpc_cli_t       server;         // BLOB server socket
                    259:                rpc_cli_t       *clients;       // connected blob client sockets
                    260: 
                    261:                rpc_blob_t      *blobs;         // registered blob variables list
                    262: 
                    263:                pthread_mutex_t mtx;
                    264:        }               srv_blob;
1.1       misho     265: } rpc_srv_t;
                    266: 
                    267: 
                    268: typedef int (*rpc_callback_t)(void * const, rpc_func_t *, int, rpc_val_t *);
                    269: 
                    270: 
                    271: // -----------------------------------------------------------------------
                    272: 
                    273: /* Error support functions */
                    274: 
                    275: // cli_GetErrno() Get error code of last operation
                    276: inline int cli_GetErrno();
                    277: // cli_GetError() Get error text of last operation
                    278: inline const char *cli_GetError();
                    279: 
                    280: 
                    281: /* RPC Server side functions */
                    282: 
                    283: /*
                    284:  * rpc_srv_initServer() Init & create RPC Server
                    285:  * @regProgID = ProgramID for authentication & recognition
                    286:  * @regProcID = ProcessID for authentication & recognition
                    287:  * @concurentClients = Concurent clients at same time to this server
                    288:  * @family = Family socket type, AF_INET or AF_INET6
                    289:  * @csHost = Host name or IP address for bind server, if NULL any address
                    290:  * @Port = Port for bind server, if Port == 0 default port is selected
                    291:  * return: NULL == error or !=NULL bind and created RPC server instance
                    292:  */
                    293: rpc_srv_t *rpc_srv_initServer(u_int regProgID, u_int regProcID, int concurentClients, 
                    294:                u_short family, const char *csHost, u_short Port);
                    295: /*
                    296:  * rpc_srv_endServer() Destroy RPC server, close all opened sockets and free resources
                    297:  * @srv = RPC Server instance
                    298:  * return: none
                    299:  */
                    300: void rpc_srv_endServer(rpc_srv_t * __restrict srv);
                    301: /*
                    302:  * rpc_srv_execServer() Execute Main server loop and wait for clients requests
                    303:  * @srv = RPC Server instance
                    304:  * return: -1 error or 0 ok, infinite loop ...
                    305:  */
                    306: int rpc_srv_execServer(rpc_srv_t * __restrict srv);
                    307: 
                    308: /*
1.1.1.1.2.5  misho     309:  * rpc_srv_initBLOBServer() Init & create BLOB Server
                    310:  * @Port = Port for bind server, if Port == 0 default port is selected
1.1.1.1.2.6  misho     311:  * @diskDir = Disk place for BLOB file objects
1.1.1.1.2.5  misho     312:  * return: -1 == error or 0 bind and created BLOB server instance
                    313:  */
1.1.1.1.2.6  misho     314: int rpc_srv_initBLOBServer(rpc_srv_t * __restrict srv, u_short Port, const char *diskDir);
1.1.1.1.2.5  misho     315: /*
                    316:  * rpc_srv_endBLOBServer() Destroy BLOB server, close all opened sockets and free resources
                    317:  * @srv = RPC Server instance
                    318:  * return: none
                    319:  */
                    320: void rpc_srv_endBLOBServer(rpc_srv_t * __restrict srv);
                    321: /*
                    322:  * rpc_srv_execBLOBServer() Execute Main BLOB server loop and wait for clients requests
                    323:  * @srv = RPC Server instance
                    324:  * return: -1 error or 0 ok, infinite loop ...
                    325:  */
                    326: int rpc_srv_execBLOBServer(rpc_srv_t * __restrict srv);
                    327: 
                    328: /*
1.1.1.1.2.6  misho     329:  * rpc_srv_getBLOB() Get registered BLOB 
                    330:  * @srv = RPC Server instance
                    331:  * @var = hash for variable
                    332:  * return: NULL not found, !=NULL return blob var
                    333:  */
                    334: inline rpc_blob_t *rpc_srv_getBLOB(rpc_srv_t * __restrict srv, uint32_t var);
                    335: 
                    336: /*
1.1       misho     337:  * rpc_srv_registerCall() Register call to RPC server
                    338:  * @srv = RPC Server instance
                    339:  * @csModule = Module name, if NULL self binary
                    340:  * @csFunc = Function name
                    341:  * @args = Number of function arguments
                    342:  * return: -1 error or 0 register ok
                    343:  */
                    344: int rpc_srv_registerCall(rpc_srv_t * __restrict srv, const char *csModule, const char *csFunc, 
                    345:                unsigned char args);
                    346: /*
                    347:  * rpc_srv_unregisterCall() Unregister call from RPC server
                    348:  * @srv = RPC Server instance
                    349:  * @csModule = Module name, if NULL self binary
                    350:  * @csFunc = Function name
                    351:  * return: -1 error, 0 not found call, 1 unregister ok
                    352:  */
                    353: int rpc_srv_unregisterCall(rpc_srv_t * __restrict srv, const char *csModule, const char *csFunc);
                    354: /*
                    355:  * rpc_srv_getFunc() Get registered call from RPC server by Name
                    356:  * @srv = RPC Server instance
                    357:  * @csModule = Module name, if NULL self binary
                    358:  * @csFunc = Function name
                    359:  * return: NULL not found call, !=NULL return call
                    360:  */
                    361: rpc_func_t *rpc_srv_getFunc(rpc_srv_t * __restrict srv, const char *csModule, const char *csFunc);
                    362: /*
                    363:  * rpc_srv_getCall() Get registered call from RPC server
                    364:  * @srv = RPC Server instance
                    365:  * @tag = tag for function
                    366:  * @hash = hash for function
                    367:  * return: NULL not found call, !=NULL return call
                    368:  */
                    369: inline rpc_func_t *rpc_srv_getCall(rpc_srv_t * __restrict srv, uint16_t tag, uint32_t hash);
                    370: /*
                    371:  * rpc_srv_execCall() Execute registered call from RPC server
                    372:  * @data = RPC const data
                    373:  * @call = Register RPC call
                    374:  * @rpc = IN RPC call structure
                    375:  * @args = IN RPC call array of rpc values
                    376:  * return: -1 error, !=-1 ok
                    377:  */
                    378: int rpc_srv_execCall(void * const data, rpc_func_t * __restrict call, 
                    379:                struct tagRPCCall * __restrict rpc, rpc_val_t * __restrict args);
                    380: 
                    381: 
                    382: /*
                    383:  * rpc_srv_declValsCall() Declare return variables for RPC call
                    384:  * @call = RPC function call
                    385:  * @return_vals = Number of return variables
                    386:  * return: -1 error, !=-1 ok
                    387:  */
                    388: inline int rpc_srv_declValsCall(rpc_func_t * __restrict call, int return_vals);
                    389: /*
                    390:  * rpc_srv_freeValsCall() Free return variables for RPC call
                    391:  * @call = RPC function call
                    392:  * return: none
                    393:  */
                    394: inline void rpc_srv_freeValsCall(rpc_func_t * __restrict call);
                    395: /*
                    396:  * rpc_srv_copyValsCall() Copy return variables for RPC call to new variable
                    397:  * @call = RPC function call
                    398:  * @newvals = New allocated variables array, must be free after use
                    399:  * return: -1 error, !=-1 Returned number of copied RPC variables
                    400:  */
                    401: inline int rpc_srv_copyValsCall(rpc_func_t * __restrict call, rpc_val_t ** __restrict newvals);
                    402: /*
                    403:  * rpc_srv_delValsCall() Clean values from return variables of RPC call
                    404:  * @call = RPC function call
                    405:  * return: -1 error, !=-1 Returned number of cleaned RPC variables
                    406:  */
                    407: inline int rpc_srv_delValsCall(rpc_func_t * __restrict call);
                    408: /*
                    409:  * rpc_srv_getValsCall() Get return variables for RPC call
                    410:  * @call = RPC function call
                    411:  * @vals = Returned variables, may be NULL
                    412:  * return: -1 error, !=-1 Number of returned variables
                    413:  */
                    414: inline int rpc_srv_getValsCall(rpc_func_t * __restrict call, rpc_val_t ** __restrict vals);
                    415: 
                    416: 
1.1.1.1.2.7  misho     417: /*
1.1.1.1.2.10! misho     418:  * rpc_srv_blobCreate() Create map blob to memory region and return object
        !           419:  * @srv = RPC Server instance
        !           420:  * @len = BLOB length object
        !           421:  * return: NULL error or !=NULL allocated BLOB object
        !           422:  */
        !           423: inline rpc_blob_t *rpc_srv_blobCreate(rpc_srv_t * __restrict srv, int len);
        !           424: /*
1.1.1.1.2.7  misho     425:  * rpc_srv_blobMap() Map blob to memory region 
                    426:  * @srv = RPC Server instance
                    427:  * @blob = Map to this BLOB element
                    428:  * return: -1 error or 0 ok
                    429:  */
                    430: inline int rpc_srv_blobMap(rpc_srv_t * __restrict srv, rpc_blob_t * __restrict blob);
                    431: /*
                    432:  * rpc_srv_blobUnmap() Unmap blob memory region 
                    433:  * @blob = Mapped BLOB element
                    434:  * return: none
                    435:  */
                    436: inline void rpc_srv_blobUnmap(rpc_blob_t * __restrict blob);
                    437: /*
                    438:  * rpc_srv_blobFree() Free blob from disk & memory
                    439:  * @srv = RPC Server instance
                    440:  * @blob = Mapped BLOB element
                    441:  * return: -1 error or 0 ok
                    442:  */
                    443: inline int rpc_srv_blobFree(rpc_srv_t * __restrict srv, rpc_blob_t * __restrict blob);
                    444: 
1.1.1.1.2.9  misho     445: /*
1.1.1.1.2.10! misho     446:  * rpc_srv_registerBLOB() Register new BLOB to server
        !           447:  * @srv = RPC Server instance
        !           448:  * @len = BLOB length
        !           449:  * return: -1 error or 0 register ok
        !           450:  */
        !           451: rpc_blob_t *rpc_srv_registerBLOB(rpc_srv_t * __restrict srv, size_t len);
        !           452: /*
        !           453:  * rpc_srv_unregisterBLOB() Unregister BLOB from server
        !           454:  * @srv = RPC Server instance
        !           455:  * @var = BLOB Variable for unregister
        !           456:  * return: -1 error, 0 not found call, 1 unregister ok
        !           457:  */
        !           458: int rpc_srv_unregisterBLOB(rpc_srv_t * __restrict srv, uint32_t var);
        !           459: 
        !           460: /*
1.1.1.1.2.9  misho     461:  * rpc_srv_sendBLOB() Send mapped BLOB to client
                    462:  * @cli = Client instance
                    463:  * @blob = Mapped BLOB element
                    464:  * return: -1 error, 0 ok
                    465:  */
                    466: int rpc_srv_sendBLOB(rpc_cli_t * __restrict cli, rpc_blob_t * __restrict blob);
                    467: /*
                    468:  * rpc_srv_recvBLOB() Receive BLOB from client
                    469:  * @cli = Client instance
1.1.1.1.2.10! misho     470:  * @blob = Mapped BLOB element
        !           471:  * return: -1 error, 0 ok, >0 unreceived data from client, may be error?
1.1.1.1.2.9  misho     472:  */
1.1.1.1.2.10! misho     473: int rpc_srv_recvBLOB(rpc_cli_t * __restrict cli, rpc_blob_t * __restrict blob);
1.1.1.1.2.9  misho     474: 
1.1.1.1.2.7  misho     475: 
1.1       misho     476: /* RPC Client side functions */
                    477: 
                    478: /*
                    479:  * rpc_cli_openClient() Connect to RPC Server
                    480:  * @ProgID = ProgramID for RPC session request
                    481:  * @ProcID = ProcessID for RPC session request
                    482:  * @family = Family socket type, AF_INET or AF_INET6
                    483:  * @csHost = Host name or IP address for bind server
                    484:  * @Port = Port for bind server, if Port == 0 default port is selected
                    485:  * return: NULL == error or !=NULL connection to RPC server established
                    486:  */
                    487: rpc_cli_t *rpc_cli_openClient(u_int ProgID, u_int ProcID, u_short family, 
                    488:                const char *csHost, u_short Port);
                    489: /*
                    490:  * rpc_cli_closeClient() Close connection to RPC server and free resources
                    491:  * @cli = RPC Client session
                    492:  * return: none
                    493:  */
                    494: void rpc_cli_closeClient(rpc_cli_t * __restrict cli);
                    495: /*
                    496:  * rpc_cli_execCall() Execute RPC call
                    497:  * @cli = RPC Client session
                    498:  * @csModule = Module name, if NULL self binary
                    499:  * @csFunc = Function name for execute
                    500:  * @in_argc = IN count of arguments
                    501:  * @in_vals = IN RPC call array of rpc values
                    502:  * @out_argc = OUT returned count of arguments
                    503:  * @out_vals = OUT returned array of rpc values, must be free after use (see rpc_cli_freeVals())
                    504:  * return: -1 error or != -1 ok result
                    505:  */
                    506: int rpc_cli_execCall(rpc_cli_t *cli, const char *csModule, const char *csFunc, int in_argc, 
                    507:                rpc_val_t * __restrict in_vals, int *out_argc, rpc_val_t ** __restrict out_vals);
                    508: /*
                    509:  * rpc_cli_freeVals() Free rpc_val_t array returned from RPC call
                    510:  * @args = Number of arguments in array
                    511:  * @vals = Value elements
                    512:  * return: none
                    513:  */
                    514: inline void rpc_cli_freeVals(int args, rpc_val_t *vals);
                    515: 
                    516: 
                    517: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>