2 * Copyright (c) 2004, Index Data.
3 * See the file LICENSE for details.
5 * $Id: test-init-08.cpp,v 1.1 2004-03-25 23:14:07 adam Exp $
9 #include <yaz/charneg.h>
10 #include <yaz/otherinfo.h>
14 Zlint_test_init_08::Zlint_test_init_08()
19 Zlint_test_init_08::~Zlint_test_init_08()
23 Zlint_code Zlint_test_init_08::init(Zlint *z)
26 Z_APDU *apdu = z->create_Z_PDU(Z_APDU_initRequest);
27 Z_InitRequest *init = apdu->u.initRequest;
29 z->msg_check_for("for init message sizes %d", m_no);
31 /* set all options.. see what target really supports .. */
32 ODR_MASK_SET(init->protocolVersion, Z_ProtocolVersion_3);
34 *init->maximumRecordSize = m_no * m_no * 100000 + 2000;
35 *init->preferredMessageSize = m_no * m_no *100000 + 2000;
37 int r = z->send_Z_PDU(apdu, &len);
40 z->msg_check_fail("unable to send init request");
46 Zlint_code Zlint_test_init_08::recv_gdu(Zlint *z, Z_GDU *gdu)
48 if (gdu->which == Z_GDU_Z3950 &&
49 gdu->u.z3950 && gdu->u.z3950->which == Z_APDU_initResponse)
51 Z_InitResponse *init = gdu->u.z3950->u.initResponse;
52 int ver = z->initResponseGetVersion(init);
53 int result = init->result ? *init->result : 0;
55 if (m_no * m_no * 100000 + 2000 < *init->maximumRecordSize)
56 z->msg_check_fail("maximumRecordSize bigger than proposed size");
57 if (m_no * m_no * 100000 + 2000 < *init->preferredMessageSize)
58 z->msg_check_fail("preferredMessage bigger than proposed size");
67 z->msg_check_fail("did not receive init response as expected");
71 Zlint_code Zlint_test_init_08::recv_fail(Zlint *z, int reason)
73 z->msg_check_fail("target closed connection");