/* begincopyright
  Copyright (c) 1988 Xerox Corporation. All rights reserved.
  Use and copying of this software and preparation of derivative works based
  upon this software are permitted. Any distribution of this software or
  derivative works must comply with all applicable United States export
  control laws. This software is made available AS IS, and Xerox Corporation
  makes no warranty about the software, its performance or its conformity to
  any specification. Any person obtaining a copy of this software is requested
  to send their name and post office or electronic mail address to:
    PCR Coordinator
    Xerox PARC
    3333 Coyote Hill Rd.
    Palo Alto, CA 94304
  endcopyright */

/*
 * CirioNubProtocol.h
 *
 * Demers, November 2, 1989 10:12:55 am PST
 *
 * CirioNub protocol.
 *
 * Bad design: CirioNubRetCode is known to all clients,
 *   so this file gets included everywhere.
 */

#ifndef ←CIRIO←NUB←PROTOCOL←
#define ←CIRIO←NUB←PROTOCOL←


#include <sys/types.h>

/*
 * well known port
 */

#define CIRIO←NUB←LISTENER←PORT		4815

#define CIRIO←NUB←PROTOCOL←VERSION	0

#define CIRIO←NUB←VERSION(proto,procs) ( ((proto)<<16) | (procs) )

/*
 * return codes
 */

typedef enum CirioNubRetCode {
    cnrc←ok = 0,
    cnrc←noProc = 1,
    cnrc←badArgs = 2,

    /* the remaining return codes require destroying the stream */

    cnrc←MUST←CLOSE←CONNECTION = 128,
    cnrc←failure = 128,
    cnrc←comm = 129,
    cnrc←protocol = 130,
    cnrc←space = 131,
    cnrc←last = 0x7fffffff
} CirioNubRetCode;


/*
 * types (of tagged values passed over the wire)
 */
 
typedef enum CirioNubTag {
    cnt←null = 0,
    cnt←procID = 1,
    cnt←retCode = 2,
    cnt←card32 = 3,
    cnt←int32 = 4,
    cnt←string = 5,
    cnt←block8 = 6,
    cnt←block16 = 7,
    cnt←block32 = 8,
    cnt←last = 0x7fff
};


/*
 * representation on the wire
 *
 * call is args followed by procID
 * reply is results followed by retCode
 */

typedef short net←short;
typedef long net←long;


typedef struct CirioNubWrapper {
    net←short cnw←tag;
    net←short cnw←len;
};

#endif /* ←CIRIO←NUB←PROTOCOL← */