home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / usr.bin / tn3270 / api / api_exch.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-26  |  5.2 KB  |  162 lines

  1. /*-
  2.  * Copyright (c) 1988 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  *    @(#)api_exch.h    4.2 (Berkeley) 4/26/91
  34.  */
  35.  
  36. /*
  37.  * This file describes the structures passed back and forth
  38.  * between the API client and API server on a Unix-based
  39.  * tn3270 implementation.
  40.  */
  41.  
  42. /*
  43.  * The following are the low-level opcodes exchanged between the
  44.  * two sides.  These are designed to allow for type, sequence number,
  45.  * and direction checking.
  46.  *
  47.  * We enforce conversation flow.  There are three states: CONTENTION,
  48.  * SEND, and RECEIVE.  Both sides start in CONTENTION.
  49.  * We never leave RECEIVE state without first reading a TURNAROUND
  50.  * opcode.  We never leave SEND state without first writing a TURNAROUND
  51.  * opcode.  This scheme ensures that we always have conversation flowing
  52.  * in a synchronized direction (or detect an application error), and that
  53.  * we never hang with both sides trying to read from the "wire".
  54.  *
  55.  * State    event            action
  56.  *
  57.  * CONTENTION    read request        send TURNAROUND
  58.  *                    read RTS
  59.  *                    enter RECEIVE
  60.  * CONTENTION    write request        send RTS
  61.  *                    read TURNAROUND
  62.  *                    enter SEND
  63.  *
  64.  * RECEIVE    read request        read whatever
  65.  * RECEIVE    write request        read TURNAROUND
  66.  *
  67.  * SEND        read request        send TURNAROUND
  68.  * SEND        write            write whatever
  69.  */
  70.  
  71. #define    EXCH_EXCH_COMMAND    0    /* The following is a command */
  72. #define    EXCH_EXCH_TURNAROUND    1    /* Your turn to send */
  73. #define    EXCH_EXCH_RTS        2    /* Request to send */
  74. #define    EXCH_EXCH_TYPE        3    /* The following is a type */
  75.  
  76. struct exch_exch {
  77.     char
  78.     opcode;            /* COMMAND, TURNAROUND, or TYPE */
  79.     unsigned char
  80.     my_sequence,        /* 0-ff, initially zero */
  81.     your_sequence,        /* 0-ff, initially zero */
  82.     command_or_type;    /* Application level command or type */
  83.     unsigned short
  84.     length;            /* The length of any following data */
  85. };
  86.  
  87. /*
  88.  * The following are the command codes which the higher level protocols
  89.  * send and receive.
  90.  */
  91.  
  92. #define    EXCH_CMD_ASSOCIATE    0    /* Connect [client->server] */
  93.     /*
  94.      * struct storage_desc
  95.      * char key[]
  96.      */
  97. #define    EXCH_CMD_DISASSOCIATE    1    /* Disconnect [client->server] */
  98. #define    EXCH_CMD_SEND_AUTH    2    /* Send password [server->client] */
  99.     /*
  100.      * struct storage_desc
  101.      * char prompt[]
  102.      * struct storage_desc
  103.      * char seed[]
  104.      */
  105. #define    EXCH_CMD_AUTH        3    /* Authorization [client->server] */
  106.     /*
  107.      * struct storage_desc
  108.      * char authenticator[]
  109.      */
  110. #define    EXCH_CMD_ASSOCIATED    4    /* Connected [server->client] */
  111. #define    EXCH_CMD_REJECTED    5    /* Too bad [server->client] */
  112.     /*
  113.      * struct storage_desc
  114.      * char message[]
  115.      */
  116.  
  117. #define    EXCH_CMD_REQUEST    6    /* A request [client->server] */
  118.     /* struct regs,
  119.      * struct sregs,
  120.      * struct storage_desc
  121.      * char bytes[]
  122.      */
  123. #define    EXCH_CMD_GIMME        7    /* Send storage [server->client] */
  124.     /*
  125.      * struct storage_desc
  126.      */
  127. #define    EXCH_CMD_HEREIS        8    /* Here is storage [BOTH WAYS] */
  128.     /*
  129.      * struct storage_desc
  130.      * char bytes[]
  131.      */
  132. #define    EXCH_CMD_REPLY        9    /* End of discussion */
  133.     /*
  134.      * struct regs,
  135.      * struct sregs,
  136.      */
  137.  
  138. /*
  139.  * The following are typed parameters sent across the wire.
  140.  *
  141.  * This should be done much more generally, with some form of
  142.  * XDR or mapped conversation ability.
  143.  */
  144.  
  145. #define    EXCH_TYPE_REGS        0
  146. #define    EXCH_TYPE_SREGS        1
  147. #define    EXCH_TYPE_STORE_DESC    2
  148. #define    EXCH_TYPE_BYTES        3
  149.  
  150. /*
  151.  * each parameter that comes over looks like:
  152.  *
  153.  *    char            type of following
  154.  *    short (2 bytes)        length of following (network byte order)
  155.  *    following
  156.  */
  157.  
  158. struct storage_descriptor {
  159.     long    location;    /* In network byte order */
  160.     short    length;        /* In network byte order */
  161. };
  162.