/* *********************************************************************
 * *	                                                               *
 * *               SIGMET NETWORK RELATED DEFINITIONS                  *
 * *                                                                   *
 * *********************************************************************
 * File: include/signetwork.h
 *
 *                 COPYRIGHT (c) 2002, 2003, 2004  BY
 *          SIGMET INCORPORATED, WESTFORD MASSACHUSETTS, U.S.A.
 * 
 * THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND  COPIED
 * ONLY  IN  ACCORDANCE WITH  THE  TERMS  OF  SUCH  LICENSE  AND WITH THE
 * INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE  OR  ANY OTHER
 * COPIES  THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
 * OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF  THE  SOFTWARE  IS  HEREBY
 * TRANSFERED.
 *
 * Include requirements: sigtypes.h
 */
#ifndef SIGMET_SIGNETWORK_H
#define SIGMET_SIGNETWORK_H 1

#ifdef __cplusplus
extern "C" {
#endif

#define MIN_USER_PORT  (5001)   /* Minumum port you should use */

/* Well known port numbers.  These can usually be overriden in
 * configuration, so these are default values.  If multiple ports are
 * needed for a similar purpose use consecutive numbers above.  For
 * example, the rtd_echo program can receive 30731, and transmit back
 * on 30730.
 */
  /* This is for output from IRIS to another IRIS */
#define PORT_NETWORK_RECEIVER  (30725)
  /* Outputs from IRIS to other programs start here */
#define PORT_UPI_RECEIVER      (30726)
#define PORT_LLWAS_SIMULATOR   (30727)

#define PORT_RTDISP            (30730)
#define PORT_SOCKET_SERVER     (30735)
#define PORT_DSPLIB_SERVER     (30740)  /* Used for DspExport */
#define PORT_ANTLIB_SERVER     (30745)  /* Used for AntExport */

  /* Note: This is the base number for IRIS inputs (other than the
   * original network receiver).  If you have multiple inputs you 
   * need to use additional numbers.  Keep a block of 30 numbers 
   * reserved here.
   */
#define PORT_INPUT_RECEIVER    (30750)

  /* Note: By convention this is the port used to export timeseries from
   * the RVP8 to a remote system.  If you are exporting back from a remote
   * system to the RVP8, use 30781.
   */
#define PORT_TSEXPORT_XMT      (30780)
#define PORT_ANTLIB_PACKETS    (30785)  /* Used for antenna serial packets */

#define PORT_N2_INTERFACE      (8820)   /* Interface to the NORDRAD2 software */

  /* Size of buffer guarenteed to hold an IRIS socket notification */
#define NOTIFY_PACKET_SIZE     (90)


#ifndef UDP_DATA_SIZE
#define UDP_DATA_SIZE 1472  /*Maximum size of data in a UDP packet */
#else

#if ( UDP_DATA_SIZE != 1472 )
#error Inconsistent definitions of UDP_DATA_SIZE
#endif

#endif

/*********************************************
 * This is CLI/XUIF and SERVER RPC STUFF
 ********************************************/

/* Number assigned by Sun for SIGMET's iris server program number
 */
#define IRIS_RPC_SERV_PROGNUM ((unsigned long)300644)

/* Version number
 */
#define IRIS_RPC_VERSION ((unsigned long)1) 

/* ---------------------------
 * IRIS CLIENT SERVER PROGRAMS
 * ----------------------------*/

/* Asynchronous data used when sending data from iris client to iris
 * server and data sendt from iris server to iris receiver
 */
#define IRIS_RPC_PROG_ASYC_XDR_IRIS_DATA   ((unsigned long)1) 

/* Synchronous data sent from iris client to iris server for check
 * maximum number of clients and available prognum for hostname sent
 */  
#define IRIS_RPC_PROG_SYC_XDR_IRIS_STARTUP_DATA      ((unsigned long)2) 

/* Synchronous data sent from iris client to iris server every 60
 * seconds.  Check if server is still alive
 */
#define IRIS_RPC_PROG_SYC_CHECK_SERVER_ALIVE  ((unsigned long)3) 

/* Synchronous data sent from iris server to iris receiver every 60
 * seconds.  Check if receiver is still alive
 */
#define IRIS_RPC_PROG_SYC_CHECK_CLIENT_ALIVE    ((unsigned long)4) 

/* Synchronous data sent from irisnset every 30 seconds to get status
 * info of iris server.  This is the same info that shows up in iris
 * Radar Status Menu in Site Status
 */
#define IRIS_RPC_PROG_SYC_STAT_INFO    ((unsigned long)5) 


/* Number not assigend by sun for sigmets rvp server program number
 */
#define RVP_RPC_SERV_PROGNUM ((unsigned long)300645)

/* Number not assigend by sun for sigmets rcp server program number
 */
#define RCP_RPC_SERV_PROGNUM ((unsigned long)300646)

/* Synchronous data sent from irisnset every 30 seconds to get status
 * info of rvp/rcp server.
 */
#define RVP_RCP_RPC_STAT_INFO    ((unsigned long)1) 

/* Range of prognum to use iris client can use
 */
#define IRIS_RPC_FIRST_PROGNUM ((unsigned long)0x40000000)
#define IRIS_RPC_LAST_PROGNUM  ((unsigned long)0x40000020)

/* Max header and buffer sizes
 */
#define SCC_HDR_SZ  64
#define IRIS_RPC_BUF_SIZE (120000)                     /* Max cli serv chars */
#define IRIS_RPC_DATA_SIZE  (IRIS_RPC_BUF_SIZE-(2*SCC_HDR_SZ))

#define CON_FREE      (0)  /* Not connected */
#define CON_STARTING  (1)  /* Waiting to make a conn, refuse multiple attempt */
#define CON_CONNECTED (2)  /* Connected to a real IRIS */
#define CON_STOPPING  (3)  /* Waiting to disconnect */
#define CON_PSEUDO    (4)  /* Pseudo connection */

struct iris_rpc_data {
        char          *rcv_hostname;
        unsigned long ircv_prognum;
        unsigned long icli_connect;
        unsigned long idata_len;
        char          *data_ptr;
};

struct iris_rpc_startup_data {
        char          *rcv_hostname;
        unsigned long iprognum_avail;
        int           imax_clients;
};

#ifdef __cplusplus
}
#endif
#endif /* #ifndef SIGMET_SIGNETWORK_H */
