2 * Copyright (c) 2004, Index Data.
3 * See the file LICENSE for details.
5 * $Id: test-init-08.cpp,v 1.5 2005-08-11 18:53:01 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;
53 if (m_no * m_no * 100000 + 2000 < *init->maximumRecordSize)
54 z->msg_check_fail("maximumRecordSize bigger than proposed size");
55 if (m_no * m_no * 100000 + 2000 < *init->preferredMessageSize)
56 z->msg_check_fail("preferredMessage bigger than proposed size");
65 z->msg_check_fail("did not receive init response as expected");
69 Zlint_code Zlint_test_init_08::recv_fail(Zlint *z, int reason)
71 z->msg_check_fail("target closed connection");
83 * indent-tabs-mode: nil
85 * vim: shiftwidth=4 tabstop=8 expandtab