Annotation of libaitrpc/inc/aitrpc_pkt.h, revision 1.2

1.2     ! misho       1: /*************************************************************************
        !             2: * (C) 2015 AITNET ltd - Sofia/Bulgaria - <misho@aitbg.com>
        !             3: *  by Michael Pounov <misho@openbsd-bg.org>
        !             4: *
        !             5: * $Author: misho $
        !             6: * $Id: aitrpc_pkt.h,v 1.1.2.1 2015/07/02 17:52:52 misho Exp $
        !             7: *
        !             8: **************************************************************************
        !             9: The ELWIX and AITNET software is distributed under the following
        !            10: terms:
        !            11: 
        !            12: All of the documentation and software included in the ELWIX and AITNET
        !            13: Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>
        !            14: 
        !            15: Copyright 2004 - 2015
        !            16:        by Michael Pounov <misho@elwix.org>.  All rights reserved.
        !            17: 
        !            18: Redistribution and use in source and binary forms, with or without
        !            19: modification, are permitted provided that the following conditions
        !            20: are met:
        !            21: 1. Redistributions of source code must retain the above copyright
        !            22:    notice, this list of conditions and the following disclaimer.
        !            23: 2. Redistributions in binary form must reproduce the above copyright
        !            24:    notice, this list of conditions and the following disclaimer in the
        !            25:    documentation and/or other materials provided with the distribution.
        !            26: 3. All advertising materials mentioning features or use of this software
        !            27:    must display the following acknowledgement:
        !            28: This product includes software developed by Michael Pounov <misho@elwix.org>
        !            29: ELWIX - Embedded LightWeight unIX and its contributors.
        !            30: 4. Neither the name of AITNET nor the names of its contributors
        !            31:    may be used to endorse or promote products derived from this software
        !            32:    without specific prior written permission.
        !            33: 
        !            34: THIS SOFTWARE IS PROVIDED BY AITNET AND CONTRIBUTORS ``AS IS'' AND
        !            35: ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            36: IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            37: ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
        !            38: FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            39: DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            40: OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            41: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            42: LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            43: OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            44: SUCH DAMAGE.
        !            45: */
        !            46: #ifndef __AITRPC_PKT_H
        !            47: #define __AITRPC_PKT_H
        !            48: 
        !            49: 
        !            50: #include <sys/types.h>
        !            51: #include <elwix.h>
        !            52: 
        !            53: 
        !            54: #define RPC_VERSION            9
        !            55: #define RPC_DEFPORT            2611
        !            56: 
        !            57: /* Additional ELWIX RPC supporting protocols */
        !            58: 
        !            59: #ifndef SOCK_STREAM
        !            60: #define SOCK_STREAM            1       /* stream socket */
        !            61: #endif
        !            62: #ifndef SOCK_DGRAM
        !            63: #define SOCK_DGRAM             2       /* datagram socket */
        !            64: #endif
        !            65: #ifndef SOCK_RAW
        !            66: #define SOCK_RAW               3       /* raw-protocol interface */
        !            67: #endif
        !            68: #define SOCK_BPF               4       /* ethernet interface */
        !            69: #define SOCK_EXT               5       /* bi-directional pipe interface */
        !            70: 
        !            71: /* RPC IP protocol number */
        !            72: 
        !            73: #define IPPROTO_ERPC           162
        !            74: 
        !            75: /* RPC call request flags */
        !            76: 
        !            77: #define RPC_REPLY              0x0
        !            78: #define RPC_NOREPLY            0x1
        !            79: 
        !            80: /* RPC call I/O direction */
        !            81: 
        !            82: #define RPC_REQ                        0x0
        !            83: #define RPC_ACK                        0x1
        !            84: 
        !            85: /* RPC builtin registed calls */
        !            86: 
        !            87: #define CALL_TAG_MAX           65535
        !            88: 
        !            89: #define CALL_SRVPING           65534
        !            90: 
        !            91: #define CALL_SRVSHUTDOWN       65533
        !            92: #define CALL_SRVCLIENTS                65532
        !            93: #define CALL_SRVCALLS          65531
        !            94: #define CALL_SRVSESSIONS       65530
        !            95: 
        !            96: #define CALL_BLOBSHUTDOWN      65529
        !            97: #define CALL_BLOBCLIENTS       65528
        !            98: #define CALL_BLOBVARS          65527
        !            99: 
        !           100: /* RPC signals */
        !           101: 
        !           102: #define SIGFBLOB               54
        !           103: 
        !           104: 
        !           105: /* RPC session identification */
        !           106: 
        !           107: typedef struct {
        !           108: #if BYTE_ORDER == LITTLE_ENDIAN
        !           109:        uint16_t        sess_instance:8;
        !           110:        uint16_t        sess_version:8;
        !           111: #endif
        !           112: #if BYTE_ORDER == BIG_ENDIAN
        !           113:        uint16_t        sess_version:8;
        !           114:        uint16_t        sess_instance:8;
        !           115: #endif
        !           116: } __packed rpc_sess_t; /* size == 2 bytes */
        !           117: 
        !           118: /* Network RPC packet - Header */
        !           119: 
        !           120: struct tagRPCCall {
        !           121:        rpc_sess_t      call_session;
        !           122: 
        !           123:        uint32_t        call_len;
        !           124:        uint32_t        call_seq;
        !           125:        uint16_t        call_crc;
        !           126: 
        !           127:        union {
        !           128:                struct {
        !           129:                        uint64_t        flags;
        !           130:                }       call_req;
        !           131:                struct {
        !           132:                        int32_t         ret;
        !           133:                        int32_t         eno;
        !           134:                }       call_rep;
        !           135:        };
        !           136: 
        !           137:        uint8_t         call_io;
        !           138:        uint16_t        call_tag;
        !           139:        uint8_t         call_argc;
        !           140:        ait_val_t       call_argv[0];
        !           141: } __packed;                    /* size == 20 bytes */
        !           142: #define RPC_CHK_NOREPLY(x)     (ntohl((u_long) (x)->call_req.flags) & RPC_NOREPLY)
        !           143: #define RPC_SET_ERRNO(x, _v)   ((x)->call_rep.eno = (int32_t) htonl((_v)))
        !           144: #define RPC_SET_RETURN(x, _v)  ((x)->call_rep.ret = (int32_t) htonl((_v)))
        !           145: 
        !           146: /* Network BLOB packet - Header */
        !           147: 
        !           148: struct tagBLOBHdr {
        !           149:        rpc_sess_t      hdr_session;
        !           150:        uint8_t         hdr_cmd;
        !           151:        uint32_t        hdr_var;
        !           152:        uint32_t        hdr_len;
        !           153:        uint32_t        hdr_ret;
        !           154:        uint8_t         hdr_pad;
        !           155: } __packed;                    /* size == 16 bytes */
        !           156: #define RPC_SET_BLOB_RET(x, _v)        ((x)->hdr_ret = (uint32_t) htonl((_v)))
        !           157: 
        !           158: /* RPC BLOB types */
        !           159: 
        !           160: typedef enum {
        !           161:        ok, error, no,                          /* for blob reply */
        !           162:        get, set, unset                         /* for blob request */
        !           163: } blob_cmd_type_t;
        !           164: 
        !           165: 
        !           166: #endif

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