2 * Copyright (C) 1995-2004, Index Data
3 * See the file LICENSE for details.
5 * $Id: session.h,v 1.2 2004-10-15 00:19:00 adam Exp $
9 * \brief Internal Header for GFS.
14 #include <sys/types.h>
15 #include <yaz/comstack.h>
18 #include <yaz/proto.h>
22 REQUEST_IDLE, /* the request is just sitting in the queue */
23 REQUEST_PENDING /* operation pending (b'end processing or network I/O*/
24 /* this list will have more elements when acc/res control is added */
27 typedef struct request
29 int len_refid; /* length of referenceid */
30 char *refid; /* referenceid */
33 Z_GDU *gdu_request; /* Current request */
34 Z_APDU *apdu_request; /* Current Z39.50 request */
35 NMEM request_mem; /* memory handle for request */
37 int size_response; /* size of buffer */
38 int len_response; /* length of encoded data */
39 char *response; /* encoded data waiting for transmission */
46 typedef struct request_q
59 ASSOC_NEW, /* not initialized yet */
60 ASSOC_UP, /* normal operation */
61 ASSOC_DEAD /* dead. Close if input arrives */
64 typedef struct association
66 IOCHAN client_chan; /* event-loop control */
67 COMSTACK client_link; /* communication handle */
68 ODR decode; /* decoding stream */
69 ODR encode; /* encoding stream */
70 ODR print; /* printing stream (for -a) */
71 char *encode_buffer; /* temporary buffer for encoded data */
72 int encoded_len; /* length of encoded data */
73 char *input_buffer; /* input buffer (allocated by comstack) */
74 int input_buffer_len; /* length (size) of buffer */
75 int input_apdu_len; /* length of current incoming APDU */
76 oid_proto proto; /* protocol (PROTO_Z3950/PROTO_SR) */
77 void *backend; /* backend handle */
78 request_q incoming; /* Q of incoming PDUs */
79 request_q outgoing; /* Q of outgoing data buffers (enc. PDUs) */
80 association_state state;
82 /* session parameters */
83 int preferredMessageSize;
84 int maximumRecordSize;
85 int version; /* highest version-bit set (2 or 3) */
89 unsigned cs_accept_mask;
91 struct bend_initrequest *init;
94 association *create_association(IOCHAN channel, COMSTACK link);
95 void destroy_association(association *h);
96 void ir_session(IOCHAN h, int event);
98 void request_enq(request_q *q, request *r);
99 request *request_head(request_q *q);
100 request *request_deq(request_q *q);
101 request *request_deq_x(request_q *q, request *r);
102 void request_initq(request_q *q);
103 void request_delq(request_q *q);
104 request *request_get(request_q *q);
105 void request_release(request *r);
107 int statserv_must_terminate(void);