File:  [ELWIX - Embedded LightWeight unIX -] / libaitrpc / inc / aitrpc_pkt.h
Revision 1.4: download - view: text, annotated - select for diffs - revision graph
Wed Mar 20 17:32:30 2024 UTC (2 months, 3 weeks ago) by misho
Branches: MAIN
CVS tags: rpc9_6, RPC9_5, HEAD
Version 9.5

    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.4 2024/03/20 17:32:30 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 - 2024
   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			0x1
   83: #define RPC_ACK			0x2
   84: #define RPC_IPC			0x4
   85: 
   86: /* RPC builtin registed calls */
   87: 
   88: #define CALL_TAG_MAX		65535
   89: 
   90: #define CALL_SRVPING		65534
   91: 
   92: #define CALL_SRVSHUTDOWN	65533
   93: #define CALL_SRVCLIENTS		65532
   94: #define CALL_SRVCALLS		65531
   95: #define CALL_SRVSESSIONS	65530
   96: 
   97: #define CALL_BLOBSHUTDOWN	65529
   98: #define CALL_BLOBCLIENTS	65528
   99: #define CALL_BLOBVARS		65527
  100: 
  101: /* RPC signals */
  102: 
  103: #define SIGFBLOB		54
  104: 
  105: 
  106: /* RPC session identification */
  107: 
  108: typedef struct {
  109: #if BYTE_ORDER == LITTLE_ENDIAN
  110: 	uint16_t	sess_instance:8;
  111: 	uint16_t	sess_version:8;
  112: #endif
  113: #if BYTE_ORDER == BIG_ENDIAN
  114: 	uint16_t	sess_version:8;
  115: 	uint16_t	sess_instance:8;
  116: #endif
  117: } __attribute__((packed)) rpc_sess_t;	/* size == 2 bytes */
  118: 
  119: /* Network RPC packet - Header */
  120: 
  121: struct tagRPCCall {
  122: 	rpc_sess_t	call_session;
  123: 
  124: 	uint32_t	call_len;
  125: 	uint32_t	call_seq;
  126: 	uint16_t	call_crc;
  127: 
  128: 	union {
  129: 		struct {
  130: 			uint64_t	flags;
  131: 		}	call_req;
  132: 		struct {
  133: 			int32_t		ret;
  134: 			int32_t		eno;
  135: 		}	call_rep;
  136: 	};
  137: 
  138: 	uint8_t		call_io;
  139: 	uint16_t	call_tag;
  140: 	uint8_t		call_argc;
  141: 	ait_val_t	call_argv[0];
  142: } __attribute__((packed));	/* size == 20 bytes */
  143: #define RPC_CHK_NOREPLY(x)	(ntohl((u_long) (x)->call_req.flags) & RPC_NOREPLY)
  144: #define RPC_SET_ERRNO(x, _v)	((x)->call_rep.eno = (int32_t) htonl((_v)))
  145: #define RPC_SET_RETURN(x, _v)	((x)->call_rep.ret = (int32_t) htonl((_v)))
  146: 
  147: /* Network BLOB packet - Header */
  148: 
  149: struct tagBLOBHdr {
  150: 	rpc_sess_t	hdr_session;
  151: 	uint8_t		hdr_cmd;
  152: 	uint32_t	hdr_var;
  153: 	uint32_t	hdr_len;
  154: 	uint32_t	hdr_ret;
  155: 	uint8_t		hdr_pad;
  156: } __attribute__((packed));			/* size == 16 bytes */
  157: #define RPC_SET_BLOB_RET(x, _v)	((x)->hdr_ret = (uint32_t) htonl((_v)))
  158: 
  159: /* RPC BLOB types */
  160: 
  161: typedef enum {
  162: 	ok, error, no, 				/* for blob reply */
  163: 	get, set, unset				/* for blob request */
  164: } blob_cmd_type_t;
  165: 
  166: 
  167: #endif

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