/* This is -*-c-*- */

/*
 * Interface to CM
 */

package RXAFSCB_

%#include <config.h>
%#include <roken.h>
%#include <fs_errors.h>

error-function conv_to_arla_errno

/*%#include "fs.h"*/

/*
 * Interface
 */

#include "common.h"

struct AFSDBLockDesc {
    char waitStates;
    char exclLocked;
    short readersReading;
    short numWaiting;
    short spare;
    int pid_last_reader;
    int pid_writer;
    int src_indicator;
};

struct AFSDBLock {
    char name[16];
    struct AFSDBLockDesc lock;
};

struct AFSDBCacheEntry {
    int32_t addr;
    int32_t cell;                         /*Cell part of the fid*/
    AFSFid netFid;                      /*Network part of the fid*/
    int32_t Length;
    int32_t DataVersion;
    struct AFSDBLockDesc lock;
    int32_t callback;
    int32_t cbExpires;
    short refCount;
    short opens;
    short writers;
    char mvstat;
    char states;
};

const AFSCB_MAX_XSTAT_LONGS = 2048;
typedef int32_t AFSCB_CollData<AFSCB_MAX_XSTAT_LONGS>;
const AFSCB_XSTATSCOLL_CALL_INFO = 0;    /*CM call counting & info*/
const AFSCB_XSTATSCOLL_PERF_INFO = 1;    /*CM performance info*/
const AFSCB_XSTATSCOLL_FULL_PERF_INFO = 2;       /*CM performance info*/

const AFS_MAX_INTERFACE_ADDR  =  32;
struct interfaceAddr {          /* for multihomed clients */
    int         numberOfInterfaces;
    afsUUID     uuid;
    int32_t     addr_in[AFS_MAX_INTERFACE_ADDR]; /* interface addresses */
    int32_t     subnetmask[AFS_MAX_INTERFACE_ADDR]; /* subnet masks in net ord */
    int32_t     mtu[AFS_MAX_INTERFACE_ADDR]; /* MTU */
};

CallBack (IN AFSCBFids *a_fidArrayP,
	  IN AFSCBs *a_callBackArrayP) = 204;

InitCallBackState () = 205;

Probe () =  206;

/* return 0 if ok, 1 if bad index, lock == lock number index */

GetLock(IN int32_t index, OUT AFSDBLock *lock) = 207;

/* return 0 if ok, 1 if bad index, cbentry == cbentry number index */

GetCE(IN int32_t index, OUT AFSDBCacheEntry *cbentry) = 208;

/* AFSCB_XSTAT_VERSION */

XStatsVersion(OUT int32_t *version) = 209;

GetXStats(IN int32_t client_version_num,
	  IN int32_t collection_number,
	  OUT int32_t *server_version_number, /* AFSCB_XSTAT_VERSION */
	  OUT int32_t *time,
	  OUT AFSCB_CollData *stats) = 210;

InitCallBackState2(OUT interfaceAddr *addr) = 211;

/* fill in interfaces et al in `addr' */

WhoAreYou(OUT interfaceAddr *addr) = 212;

/* to be done */

InitCallBackState3(IN afsUUID *serverUuid) = 213;

/* still there?  0 if match, !0 otherwise */

ProbeUUID(IN afsUUID *uuid) = 214;
