2 * Copyright (C) 1995-2005, Index Data ApS
3 * See the file LICENSE for details.
5 * $Id: session.h,v 1.6 2005-03-01 20:37:01 adam Exp $
9 * \brief Internal Header for GFS.
14 #include <yaz/comstack.h>
18 #include <yaz/proto.h>
19 #include <yaz/backend.h>
23 statserv_options_block cb;
26 cql_transform_t cql_transform;
27 struct gfs_server *next;
33 struct gfs_listen *next;
37 REQUEST_IDLE, /* the request is just sitting in the queue */
38 REQUEST_PENDING /* operation pending (b'end processing or network I/O*/
39 /* this list will have more elements when acc/res control is added */
42 typedef struct request
44 int len_refid; /* length of referenceid */
45 char *refid; /* referenceid */
48 Z_GDU *gdu_request; /* Current request */
49 Z_APDU *apdu_request; /* Current Z39.50 request */
50 NMEM request_mem; /* memory handle for request */
52 int size_response; /* size of buffer */
53 int len_response; /* length of encoded data */
54 char *response; /* encoded data waiting for transmission */
61 typedef struct request_q
74 ASSOC_NEW, /* not initialized yet */
75 ASSOC_UP, /* normal operation */
76 ASSOC_DEAD /* dead. Close if input arrives */
79 typedef struct association
81 IOCHAN client_chan; /* event-loop control */
82 COMSTACK client_link; /* communication handle */
83 ODR decode; /* decoding stream */
84 ODR encode; /* encoding stream */
85 ODR print; /* printing stream (for -a) */
86 char *encode_buffer; /* temporary buffer for encoded data */
87 int encoded_len; /* length of encoded data */
88 char *input_buffer; /* input buffer (allocated by comstack) */
89 int input_buffer_len; /* length (size) of buffer */
90 int input_apdu_len; /* length of current incoming APDU */
91 oid_proto proto; /* protocol (PROTO_Z3950/PROTO_SR) */
92 void *backend; /* backend handle */
93 request_q incoming; /* Q of incoming PDUs */
94 request_q outgoing; /* Q of outgoing data buffers (enc. PDUs) */
95 association_state state;
97 /* session parameters */
98 int preferredMessageSize;
99 int maximumRecordSize;
100 int version; /* highest version-bit set (2 or 3) */
102 unsigned cs_get_mask;
103 unsigned cs_put_mask;
104 unsigned cs_accept_mask;
106 struct bend_initrequest *init;
107 statserv_options_block *last_control;
108 cql_transform_t cql_transform;
111 association *create_association(IOCHAN channel, COMSTACK link,
112 const char *apdufile);
113 void destroy_association(association *h);
114 void ir_session(IOCHAN h, int event);
116 void request_enq(request_q *q, request *r);
117 request *request_head(request_q *q);
118 request *request_deq(request_q *q);
119 request *request_deq_x(request_q *q, request *r);
120 void request_initq(request_q *q);
121 void request_delq(request_q *q);
122 request *request_get(request_q *q);
123 void request_release(request *r);
125 int statserv_must_terminate(void);
127 int control_association(association *assoc, const char *host, int force);