/****************************************************************
 *                                                              *
 *  LIBDIST V1.0						*
 *                                                              *
 *  config.h -- configuration options				*
 *                                                              *
 *  Last changed: 01.12.98                                      *
 *  Author: Frank Kargl (frank.kargl@informatik.uni-ulm.de)     *
 *                                                              *
 *  Restrictions: works only for Solaris 2.6 or above           *
 *                                                              *
 ****************************************************************/

#ifndef CONFIG_H

#define CONFIG_H

/*** General return codes ***/
#define DL_ERROR	(-1)
#define DL_OK		( 0)

/*** Buffer sizes ***/
#define DL_MAXLINE 256		/* Maximum length of a single line */

/****************************************************************
 * PART ONE: thread handling                                    *
 ****************************************************************/

/*** Error codes ***/
#define DL_THR_NSS 1    /* No such signal */
#define DL_THR_NST 2    /* No such thread */

/****************************************************************
 * PART TWO: communication primitives                           *
 ****************************************************************/

/*** Protocol types ***/
#define DL_SCK_TCP 0 /* TCP type */
#define DL_SCK_UDP 1 /* UDP type */

/*** Queue length for listen() ***/
#define QLEN 5		/* queue length for accepts */

/*** Buffer sizes ***/
#define DL_SCK_MAXELE	32	/* Maximum number of descriptors used */

/*** Interface name ***/
#ifdef __i386__
#define DL_SCK_ETHER "nei0"
#endif
#ifdef __sparc__
#define DL_SCK_ETHER "hme0"
#endif

/****************************************************************
 * PART THREE: signal handling                                  *
 ****************************************************************/

/*** Maximum number of signal handlers to be active at once ***/
#define DL_SIG_MAXSIG	32	/* Maximum value of signal number */

/****************************************************************
 * PART FOUR: semaphores                                        *
 ****************************************************************/

/*** Buffer sizes ***/
#define DL_SEM_NSIZE 64         /* Length of a semaphore name */
#define DL_SEM_ESIZE 32         /* Maximum number of semaphores used */

/*** a uninitialized semaphore sema_t ***/
#define DL_SEM_UISEM { -1,0,0,{0,0,0},{0,0} }

/****************************************************************
 * PART FIVE: distributed shared memory                         *
 ****************************************************************/

/*** the size of a page ***/
#define DL_DSM_SIZE PAGESIZE

/*** timeout in usec */
#define DL_DSM_TIMEOUT 1000
#define DL_DSM_TIMEDOUT 1

/*** request string ***/
#define DL_DSM_REQUEST "REQUEST\r\n"

/*** the size of a key ***/
#define DL_DSM_KEYSIZE 10

/*** maximum number of active pages ***/
#define DL_DSM_MAXPAGES 1

/*** port range to use for communication ***/
#define DL_DSM_MINPORT 60000
#define DL_DSM_MAXPORT 60010

/****************************************************************
 * PART SIX: naming service                                     *
 ****************************************************************/

/*** Port to use for nameservice ***/
#define DL_NS_PORT "6543"	/* UDP Port used by Nameservice */

/*** Buffer sizes ***/
#define DL_NS_KEYLENGTH 128	/* Maximum length of a key */
#define DL_NS_DATALENGTH 128	/* Maximum length of the data */

/*** Timeout ***/
#define DL_NS_TIMEOUT (1000)	/* 1000 usec timeout when waiting for reply */

/*** Return Codes ***/
#define DL_NS_NOTFOUND -2
#define DL_NS_TIMEDOUT -3

/*** Protocol strings ***/
#define ERRORMSG "ERROR\r\n"            /* error message */
#define OKMSG "OK\r\n"                  /* ok message */
#define NOTFOUNDMSG "NOTFOUND\r\n"      /* not found message */
#define REPLYMSG "R %s %s\r\n"          /* reply message */

/****************************************************************
 * PART SEVEN: election algorithm                               *
 ****************************************************************/

/*** 
 *** Protocol for elections:
 ***
 *** A <port><CR><LF>           add port to distribution list
 *** R <port><CR><LF>           remove port from distribution list
 *** E <IPSUM> <PORT><CR><LF>   do election
 *** W <IP-ADDR> <PORT><CR><LF> announce the winner of an election
 ***/

/*** Signal used to stop server ***/
#define DL_EL_SIGNAL SIGUSR1	/* signal used to stop server */

/*** Port number where to begin scan for free ports ***/
#define DL_EL_PORTB 50000       /* where to start looking for a free port */

/*** Timeout for election ***/
#define DL_EL_TIMEOUT (1000*2)	/* timeout in usec */

/****************************************************************
 * PART EIGHT: berkeley time synchronisation (implemented later)*
 ****************************************************************/

/*******************************************************************
 * THE END                                                         *
 *******************************************************************/

#endif /* CONFIG_H */
