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