Diff for /libaitrpc/inc/aitrpc_pkt.h between versions 1.1 and 1.2

version 1.1, 2015/07/02 17:52:52 version 1.2, 2015/07/02 22:28:14
Line 0 Line 1
   /*************************************************************************
   * (C) 2015 AITNET ltd - Sofia/Bulgaria - <misho@aitbg.com>
   *  by Michael Pounov <misho@openbsd-bg.org>
   *
   * $Author$
   * $Id$
   *
   **************************************************************************
   The ELWIX and AITNET software is distributed under the following
   terms:
   
   All of the documentation and software included in the ELWIX and AITNET
   Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>
   
   Copyright 2004 - 2015
           by Michael Pounov <misho@elwix.org>.  All rights reserved.
   
   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions
   are met:
   1. Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
   2. Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
   3. All advertising materials mentioning features or use of this software
      must display the following acknowledgement:
   This product includes software developed by Michael Pounov <misho@elwix.org>
   ELWIX - Embedded LightWeight unIX and its contributors.
   4. Neither the name of AITNET nor the names of its contributors
      may be used to endorse or promote products derived from this software
      without specific prior written permission.
   
   THIS SOFTWARE IS PROVIDED BY AITNET AND CONTRIBUTORS ``AS IS'' AND
   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   SUCH DAMAGE.
   */
   #ifndef __AITRPC_PKT_H
   #define __AITRPC_PKT_H
   
   
   #include <sys/types.h>
   #include <elwix.h>
   
   
   #define RPC_VERSION             9
   #define RPC_DEFPORT             2611
   
   /* Additional ELWIX RPC supporting protocols */
   
   #ifndef SOCK_STREAM
   #define SOCK_STREAM             1       /* stream socket */
   #endif
   #ifndef SOCK_DGRAM
   #define SOCK_DGRAM              2       /* datagram socket */
   #endif
   #ifndef SOCK_RAW
   #define SOCK_RAW                3       /* raw-protocol interface */
   #endif
   #define SOCK_BPF                4       /* ethernet interface */
   #define SOCK_EXT                5       /* bi-directional pipe interface */
   
   /* RPC IP protocol number */
   
   #define IPPROTO_ERPC            162
   
   /* RPC call request flags */
   
   #define RPC_REPLY               0x0
   #define RPC_NOREPLY             0x1
   
   /* RPC call I/O direction */
   
   #define RPC_REQ                 0x0
   #define RPC_ACK                 0x1
   
   /* RPC builtin registed calls */
   
   #define CALL_TAG_MAX            65535
   
   #define CALL_SRVPING            65534
   
   #define CALL_SRVSHUTDOWN        65533
   #define CALL_SRVCLIENTS         65532
   #define CALL_SRVCALLS           65531
   #define CALL_SRVSESSIONS        65530
   
   #define CALL_BLOBSHUTDOWN       65529
   #define CALL_BLOBCLIENTS        65528
   #define CALL_BLOBVARS           65527
   
   /* RPC signals */
   
   #define SIGFBLOB                54
   
   
   /* RPC session identification */
   
   typedef struct {
   #if BYTE_ORDER == LITTLE_ENDIAN
           uint16_t        sess_instance:8;
           uint16_t        sess_version:8;
   #endif
   #if BYTE_ORDER == BIG_ENDIAN
           uint16_t        sess_version:8;
           uint16_t        sess_instance:8;
   #endif
   } __packed rpc_sess_t;  /* size == 2 bytes */
   
   /* Network RPC packet - Header */
   
   struct tagRPCCall {
           rpc_sess_t      call_session;
   
           uint32_t        call_len;
           uint32_t        call_seq;
           uint16_t        call_crc;
   
           union {
                   struct {
                           uint64_t        flags;
                   }       call_req;
                   struct {
                           int32_t         ret;
                           int32_t         eno;
                   }       call_rep;
           };
   
           uint8_t         call_io;
           uint16_t        call_tag;
           uint8_t         call_argc;
           ait_val_t       call_argv[0];
   } __packed;                     /* size == 20 bytes */
   #define RPC_CHK_NOREPLY(x)      (ntohl((u_long) (x)->call_req.flags) & RPC_NOREPLY)
   #define RPC_SET_ERRNO(x, _v)    ((x)->call_rep.eno = (int32_t) htonl((_v)))
   #define RPC_SET_RETURN(x, _v)   ((x)->call_rep.ret = (int32_t) htonl((_v)))
   
   /* Network BLOB packet - Header */
   
   struct tagBLOBHdr {
           rpc_sess_t      hdr_session;
           uint8_t         hdr_cmd;
           uint32_t        hdr_var;
           uint32_t        hdr_len;
           uint32_t        hdr_ret;
           uint8_t         hdr_pad;
   } __packed;                     /* size == 16 bytes */
   #define RPC_SET_BLOB_RET(x, _v) ((x)->hdr_ret = (uint32_t) htonl((_v)))
   
   /* RPC BLOB types */
   
   typedef enum {
           ok, error, no,                          /* for blob reply */
           get, set, unset                         /* for blob request */
   } blob_cmd_type_t;
   
   
   #endif

Removed from v.1.1  
changed lines
  Added in v.1.2


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