/*****************************************************************************/
/**                               netinel.h                                 **/
/*****************************************************************************/
#ifndef __NETINEL_H
 #define __NETINEL_H
#endif

/*****************************************************************************/
/**                        Application-specific defines                     **/
/*****************************************************************************/
#define func_type WINAPI

/*****************************************************************************/
/**           ERROR CODES returned by the client interface routines         **/
/*****************************************************************************/
#define CL_SUCCESS                      (  0)
#define NN_SERVER_NOT_FOUND             ( -1)
#define NN_INVALID_CONNECTION           ( -2)
#define NN_ALGO_NOT_FOUND               ( -3)
#define NN_OUT_OF_HANDLES               ( -4)
#define NN_HANDLE_ALREADY_LOCKED        ( -5)
#define NN_HANDLE_LOCKED                ( -6)
#define NN_INVALID_FUNCTION             ( -7)
#define NN_INVALID_UNIT                 ( -8)
#define CL_RPC_ERROR                    ( -9)
#define CL_ALGO_NOT_FOUND               (-10)
#define CL_OUT_OF_HANDLES               (-11)
#define CL_NO_NETINEL_SERVERS           (-12)
#define CL_BAD_HANDLE                   (-13)
#define CL_NO_MORE_KEYS                 (-14)
#define CL_HANDLE_LOCKED                (-15)
#define CL_HANDLE_ALREADY_LOCKED        (-16)
#define CL_SERVER_DIED                  (-17)
#define CL_SERVER_PROTOCOL              (-18)
#define CL_NETWORK_INIT                 (-19)
#define CL_SERVER_NOT_FOUND             (-20)
#define CL_CANNOT_CONNECT               (-21)
#define CL_SERVER_BUSY                  (-22)
#define NN_KEY_REMOVED                  (-23)
#define CL_CLIENT_BUSY                  (-24)
#define CL_TASK_TABLE_FULL              (-25)
#define CL_API_ERROR                    (-26)
#define CL_INVALID_REQUEST              (-27)
#define CL_INVALID_HANDLE_TBL_REQ       (-28)
#define CL_MEMORY_ALLOCATION_ERR        (-29)
#define CL_VERSION_NOT_SUPPORTED        (-30)
#define CL_LOADER_NOT_INSTALLED         (-31)
#define CL_UNSUPPORTED_PROTOCOL         (-32)
#define CL_ASL_OPTION_NOT_AVAILABLE     (-33)
#define CL_ASL_MAX_LICENSE_REACHED      (-34)
#define CL_ASL_LICENSE_TABLE_FULL       (-35)
#define CL_ASL_KEY_REMOVED              (-36)
#define CL_ASL_KEY_CONTENT_CHANGED      (-37)
#define CL_ASL_OUT_OF_RANGE             (-38)
#define CL_ASL_NOT_INUSE_BY_YOU         (-39)
#define CL_INVALID_ASLCMD               (-40)
#define CL_ASL_RSP_PTR_NULL             (-41)
#define CL_INVALID_SUBLICENSE           (-42)
#define CL_FNCT_NOT_AVAIL_IN_LOCAL_MODE (-43)
#define CL_INIT_THREAD_ERR              (-44)
#define CL_INIT_SEM_ERR                 (-45)
#define CL_INIT_PROTOCOL_ERR            (-46)
#define NN_BAD_HANDLE                   (-47)
#define NN_GET_LIB_PARAMS_ERROR        (-48)
#define NN_INVALID_LIB_PARAMS_FUNC      (-49)
#define NN_INVALID_KEY_TYPE                    (-50)
#define NN_SET_LIB_PARAMS_ERROR         (-51)
#define CL_DRVR_CONFIGURE_ERR           (-52)
#define CL_GET_DRVR_INFO_ERR            (-53)
#define CL_INIT_RDP_ERR                 (-54)
#define CL_HANDLE_NOT_FOUND             (-55)
#define CL_TASK_NOT_FOUND               (-56)



/*****************************************************************************/
/**                             #define section                             **/
/*****************************************************************************/

#define QUERY_DATA_SIZE              64   /* size of a block for query_key() */
#define QC_READ_OP                    1   /* values for C_CMD_BLOCK          */
#define QC_HIGH_WATER                60
#define QC_RESERVED_1                60
#define QC_SERIAL_NO                 61
#define QC_DEV_ID                    62
#define QC_PRODUCT_CODE              63
#define STATS_BLOCK_SIZE           2500
#define WPF_YIELD                     1
#define WPF_NETBIOS_CMDS              2
#define WPF_SET_PROTOCOL              4
#define SRWP_FLAGS            WPF_YIELD
#define NETWORK_NAME_SIZE            64

/*****************  Access Sub license Op Code  *****************/
#define ASL_OPEN                      0
#define ASL_CLOSE                     1
#define ASL_GET_INFO                  2

/******************  Following are transport type identifiers  ***************/
#define XP_FIRST                      0   /* Matches 1st entry.              */
#define XP_DEFAULT                    0   /* Chosen by client lib.           */
#define XP_IPX                        1   /* IPX/SPX                         */
#define XP_PIPES                      2   /* Named Pipes                     */
#define XP_NBIOSN                     3   /* NetBIOS (NETAPI)                */
#define XP_NBIOSA                     4   /* NetBIOS (NB30 via ACSNETB)      */
#define XP_LOCAL                      5   /* Local server                    */
#define XP_NWLINK_IPX                 6   /* Microsoft's version of IPX/SPX  */
#define XP_NETBIOS_ANY                7   /* Scan's all NetBIOS lana's       */
#define XP_TCP_IP                     8   /* Microsoft's TCP/IP stack  'T'   */
#define XP_LAST                       8   /* Matches last entry              */
#define XP_TERMINATOR               255   /* Input-terminator for partially  */
					  /*       filled-in array           */
#define XP_UNUSED                   255   /* Response-unused array element   */
#define XP_SKIP                       0   /* Internal use-unsed array element*/
#define PROTOCOL_ARRAY_SIZE          16   /* Size of protocols in RNBO_PARMS */

#define SUBNET_MASK_LEN_TCPIP        17
                             /* i.e. length of "255.255.255.255" + 2... */


#define RBP_USE_HARDWIRED_PPORTS      1   /* Use parallel port addrs         */
					  /* defined by the library          */
#define RBP_USE_SPECIFIED_PPORTS      2   /* Use parallel port addrs         */
					  /* as specified by parms           */
#define RBP_DEFINE_DEPARTMENT_NAME    3   /* Define department name          */
					  /* to access specific servers      */
#define RBP_USE_MAX_SERVERS           4   /* Use to limit the number         */
					  /* of servers searched per         */
					  /* IPX and NetBIOS transports      */
#define RBP_DEFINE_PROTOCOLS          5   /* Set client protocols from       */
					  /* array protocols.                */
#define RBP_DEFINE_WAIT_TIMES         6    /* Set the Win32 clients wait */
                                           /* values                     */
#define RBP_USE_LOCAL_NETNAME         7   /* define how to create            */
					  /* NetBIOS local name.             */
#define RBP_SET_MACHINE_TYPE          9   /* Set to a specific machine.      */
					  /*   (IBM, NEC, FMR)               */
#define RBP_SET_DRIVER_TYPE           10  /* Set the specific router         */
					  /*   (Linkedin, System)            */
#define RBP_SET_ERROR_MODE            11  /* Set the error mode for          */
					  /*   compatible or extended.       */
#define RBP_SET_TIMEOUT               12  /* Set the timeout                 */

#define RBP_SET_TCPIP_TIMEOUT_SEC     13    /* Set timeout delay (sec)    */
                                            /* TCP/IP Only                */

#define RBP_SET_TCPIP_RETRIES         14    /* Set # of retries           */
                                            /* TCP/IP Only                */

#define RBP_SET_TCPIP_SUBNET_MASK     15    /* Set Subnet Mask            */
                                            /* Null-term string 15 + null */
                                            /* TCP/IP Only                */

#define RBP_GET_DRIVER_INFO           1   /* Use driver info                 */
#define RBP_GET_KEY_INFO              2   /* Use to be Get_Info              */
#define RBP_GET_SERVER_INFO           3   /* Use to be Get_Server_Info       */



#define RB_AUTO_MACHINE               0   /* defines AUTOdetect              */
#define RB_IBM_MACHINE                1   /* defines IBM type hw             */
#define RB_NEC_MACHINE                2   /* defines NEC PC-9800 hw          */
#define RB_FMR_MACHINE                3   /* defines Fujitsu FMR hw          */

#define RB_ROUTER_USE_LOCAL_DRVR  0x0001  /* use linked in driver            */
#define RB_ROUTER_USE_SYS_DRVR    0x0002  /* use system driver               */
#define RB_ROUTER_AUTODETECT_DRVR (RB_ROUTER_USE_LOCAL_DRVR | \
				   RB_ROUTER_USE_SYS_DRVR)

/* Define the cmd field values for RB_NC_LIB_PARAMS  */
#define RB_COMPATIBLE_ERROR_MODE      0  /* Compatible error mode           */
#define RB_EXTENDED_ERROR_MODE        1  /* Extended error mode             */


#define SERVER_NAME_SIZE              9
#define USE_PERMANENT_NODE_NAME       1   /* Use permanent node name as      */
					  /* NetBIOS local network name      */
#define CREATE_NETBIOS_UNIQUE_NAME    2   /* Add unique NetBIOS name as      */
					  /* NetBIOS local network name      */


/*****************************************************************************/
/**                             #typedef section                            **/
/*****************************************************************************/

typedef struct c_cmd_block {
     unsigned short int  COMMAND;
     unsigned short int  CELL_ADDRESS;
     unsigned short int  CELL_DATA;
} C_CMD_BLOCK;


typedef union query_data {
    unsigned char        PRO[ QUERY_DATA_SIZE ];
    C_CMD_BLOCK          C;
} QUERY_DATA;


typedef struct key_info_block {
    short int            max_clients;     /* maximum number of open handles  */
					  /* 0 for unlimited handles         */
    short int            client_count;    /* currently opened handles        */
    short int            locked;          /* flag to indicate locked         */
    unsigned long int    time_out_ticks;
} KEY_INFO_BLOCK;


typedef struct stats_block {
   unsigned char         size[STATS_BLOCK_SIZE];
}STATS_BLOCK;


typedef struct {
   long                 flags;            /* For version compatibility       */
   short int            handle;           /* -1   All client handles         */
   short int            yield;            /* Yield to Windows during         */
					  /* network ops:   0 = disabled     */
					  /*                1 = enabled      */
   FARPROC              busyFunc;         /* App's function called by DLL    */
   short int            netbios_commands; /* Max NetBIOS cmds concurrently   */
   unsigned char        protocols[PROTOCOL_ARRAY_SIZE];
					  /* protocols for client LIBRARY    */
} RNBO_PARMS;

typedef struct {
    KEY_INFO_BLOCK k2;
    short int handle;
} KEY_INFO_BLOCK_W_HANDLE;

typedef struct {
   short int             port1;
   short int             port2;
   short int             port3;
} PPORTS;

typedef struct {
   short int major_ver;
   short int minor_ver;
   short int revision;
   short int os_drv_type;
} version_struct;

typedef struct
  {
  DWORD NWLINK_pollingSapRetry;
  DWORD NWLINK_nonPollingSapRetry;
  DWORD NWLINK_sapQueryDelay;
  DWORD NWLINK_connectCmplt;
  } WAITS_T, *WAITS_PTR_T;

typedef struct  {
  DWORD TCPIP_pollingSapRetry;
  DWORD TCPIP_nonPollingSapRetry;
  DWORD TCPIP_sapQueryDelay;
  DWORD TCPIP_connectCmplt;
  } TCPIP_WAITS_T, *TCPIP_WAITS_PTR_T;

typedef union {
   unsigned char           protocols[PROTOCOL_ARRAY_SIZE];
   char                    deptname[SERVER_NAME_SIZE];
   short                   max_servers;
   WAITS_T                 waitTimes;
   PPORTS                  pports;
   short                   nb_local_name_opt;
   short                   ipxspx_receive_timeout;
   short                   machine_type;
   short                   driver_type;
   short                   error_mode;
   version_struct          version;
   KEY_INFO_BLOCK_W_HANDLE keyinfo;
   DWORD                   timeout_sec_TCPIP;
   DWORD                   timeout_retries_TCPIP;
   char                    subnet_mask_TCPIP[ SUBNET_MASK_LEN_TCPIP ];
} RB_PARAMETERS_T, *RB_PARAMETERS_PTR_T;

typedef struct {
   unsigned short int    rnbo_func;
   RB_PARAMETERS_T       p2;
} RNBO_PARAMETERS_T, *RNBO_PARAMETERS_PTR_T;

typedef struct {
   unsigned short asl_command;
   unsigned short asl_sublicense;
} ASL_PARAMS;

typedef struct {
   unsigned short    asr_sublicense;
   unsigned long     asr_present_total;
   unsigned long     asr_present_inuse_by_all;
   unsigned long     asr_present_inuse_by_you;
   unsigned long     asr_missing_inuse_by_all;
   unsigned long     asr_missing_inuse_by_you;
} ASL_RESPONSE;

/* type definition for an information block used by get_server_info() */
typedef struct {
       unsigned short   major_version;
       unsigned short   minor_version;
       unsigned short   number_of_keys;
       unsigned long    startup_timestamp;
       char             network_name[NETWORK_NAME_SIZE];
} SERVER_INFO_BLOCK;

typedef struct {
		unsigned short                          machine_type;
		unsigned short                          driver_type;
		unsigned short                          error_mode;
		unsigned char                           os_driver_type;
		unsigned char                           major_version;
		unsigned char                           minor_version;
		unsigned char                           revision;
} DRVR_INFO;

typedef union {
   DRVR_INFO               drv_info;
   KEY_INFO_BLOCK          key_info;
   SERVER_INFO_BLOCK       srvr_info;
} RB_GET_PARAMETERS_T, *RB_GET_PARAMETERS_PTR_T;

typedef struct
{
  unsigned short int   rnbo_func;
  RB_GET_PARAMETERS_T      p2;
} RNBO_GET_PARAMETERS_T, FAR *RNBO_GET_PARAMETERS_PTR_T;

/*****************************************************************************/
/**                       the client interface routines                     **/
/*****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif

extern short int func_type    cancel_lock_key(   short int  handle );

extern short int func_type    close_key(         short int handle );

extern void func_type         detach_from_dll(   void);

extern void func_type         detach_from_dll_II(short int handle);

extern short int func_type    get_info_key(      short int handle,
						 struct key_info_block
						  *info);
extern short unsigned int func_type
			      get_statistics(    STATS_BLOCK  *user_block,
						 short unsigned int block_size,
						 BOOL  reset_after_get);

extern short int func_type    lock_key(          short int  handle );

extern short int func_type    open_first_key(    char type_id,
						 long algo_id);

extern short int func_type    open_next_key(     short int handle );

extern short int func_type    query_key(         short int handle,
						 union query_data  *data );

extern short int func_type    set_blocking_mode( short int handle,
						 short int bmode );

extern short int func_type    set_info_key(      short int  handle,
						 struct key_info_block
						  *info );

extern short int func_type    set_rnbo_windows_parms( RNBO_PARMS  *pstruct);

extern short int func_type    set_rnbo_lib_parameters(RNBO_PARAMETERS_PTR_T
						      pstruct);

extern short int func_type    get_rnbo_lib_parameters( short int handle,
					RNBO_GET_PARAMETERS_PTR_T pstruct);

extern short int func_type    unlock_key(        short int  handle );

extern short int func_type    access_sub_license( short int handle,
				ASL_PARAMS *params, ASL_RESPONSE *response);

extern short int func_type    get_server_info( short int handle,
				SERVER_INFO_BLOCK *info);
#ifdef __cplusplus
};
#endif
